Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Database : IDisposable
- {
- MySqlConnection conn
- public Database()
- {
- conn = new MySqlConnection(connectionString);
- }
- public DataTable GetDataTable(string sql, List<MySqlParameter> args)
- {
- DataTable dt = new DataTable();
- MySqlDataAdapter da = new MySqlDataAdapter();
- using (MySqlCommand cmd = new MySqlCommand(sql, conn))
- {
- if (args.Count > 0)
- {
- cmd.Parameters.AddRange(args.ToArray());
- }
- da.SelectCommand = cmd;
- da.Fill(dt);
- }
- if (dt.Rows.Count > 0)
- {
- return dt;
- }
- else
- {
- return null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement