private void button_retrievekb_Click(object sender, EventArgs e) { SDA = new SqlDataAdapter(@"SELECT * From Table1", con); ds = new DataSet(); SDA.fill(ds, "SomeName"); dataGridView1.DataSource = ds.Tables[0]; }
private void btnLogin_Click(object sender, EventArgs e) { SqlConnection sqlcon = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=D:\Login App PBO\LoginDB.mdf;Integrated Security=True;Connect Timeout=30"); string query = "Select * from Table where username = '******' and password = '******'"; SqlDataAdapter sda = new SqlDataAdapter(query, sqlcon); DataTable dtbl = new DataTable(); sda.fill(dtbl); if(dtbl.Rows.Count== 1) { frmMain objFrmMain = new frmMain(); this.Hide(); objFrmMain.Show(); } else { MessageBox.Show("Please Check Your Username And Password); } }