public Form2() { InitializeComponent(); table = new DataTable(); table.Columns.Add(new DataColumn("epc", typeof(string))); table.Columns.Add(new DataColumn("time", typeof(string))); table.Columns.Add(new DataColumn("ant", typeof(string))); dataGridView1.DataSource = table; var headers = dataGridView1.Columns.Cast <DataGridViewColumn>(); sb.AppendLine(string.Join(",", headers.Select(column => "\"" + column.HeaderText + "\"").ToArray()) + ",\"" + "point" + "\""); databasecmd = new ConnectDatabase(); }
private bool validate_login(string user, string pass) { databasecmd = new ConnectDatabase(); databasecmd.connectDB(); databasecmd.cmd.CommandText = "Select username , password from login where username=@user and password=@pass"; databasecmd.cmd.Parameters.AddWithValue("@user", user); databasecmd.cmd.Parameters.AddWithValue("@pass", pass); databasecmd.cmd.Connection = databasecmd.connection; MySqlDataReader login = databasecmd.cmd.ExecuteReader(); if (login.Read()) { databasecmd.connection.Close(); return(true); } else { databasecmd.connection.Close(); return(false); } }
public ConnectDatabase() { Instance = this; _connection = new MySqlConnection(MyConnectionString); _cmd = new MySqlCommand("", connection); }