SHARE
TWEET

Untitled

Ortund Jun 12th, 2013 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Database : IDisposable
  2. {
  3.         MySqlConnection conn
  4.  
  5.         public Database()
  6.         {
  7.             conn = new MySqlConnection(connectionString);
  8.         }
  9.  
  10.         public DataTable GetDataTable(string sql, List<MySqlParameter> args)
  11.         {
  12.             DataTable dt = new DataTable();
  13.             MySqlDataAdapter da = new MySqlDataAdapter();
  14.  
  15.             using (MySqlCommand cmd = new MySqlCommand(sql, conn))
  16.             {
  17.                 if (args.Count > 0)
  18.                 {
  19.                     cmd.Parameters.AddRange(args.ToArray());
  20.                 }
  21.  
  22.                 da.SelectCommand = cmd;
  23.                 da.Fill(dt);
  24.             }
  25.  
  26.             if (dt.Rows.Count > 0)
  27.             {
  28.                 return dt;
  29.             }
  30.             else
  31.             {
  32.                 return null;
  33.             }
  34.         }
  35. }
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