daily pastebin goal
8%
SHARE
TWEET

Untitled

a guest Dec 16th, 2018 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using MySql.Data.MySqlClient;
  6. using System.Data;
  7.  
  8. namespace UserMail
  9. {
  10.     public class Database
  11.     {
  12.         static string connStr = "data source=localhost; initial catalog=mail; user id=root; password=Ly@12157114;";
  13.         MySqlConnection conn = new MySqlConnection(connStr);
  14.  
  15.         public MySqlDataReader getReader(string sql, List<MySqlParameter> args)
  16.         {
  17.             if (args.Count == 0)
  18.             {
  19.                 return getReader(sql);
  20.             }
  21.             else
  22.             {
  23.                 return getReader(sql, args.ToArray());
  24.             }
  25.         }
  26.         public MySqlDataReader getReader(string sql, MySqlParameter[] args = null)
  27.         {
  28.             MySqlCommand cmd = new MySqlCommand(sql, conn);
  29.  
  30.             if (args != null)
  31.             {
  32.                 cmd.Parameters.AddRange(args.ToArray());
  33.             }
  34.  
  35.             MySqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
  36.  
  37.             return dr;
  38.         }
  39.     }
  40. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top