Ругается на "sda.Fill(dt);" private void button1_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Вячеслав\Desktop\БД\WindowsFormsApplication1\WindowsFormsApplication1\Database1.mdf;Integrated Security=True"); SqlDataAdapter sda = new SqlDataAdapter("Select Count(*) from User where Login='"+textBox1.Text+"' and Password='"+textBox2.Text+"'", con ); DataTable dt = new DataTable(); sda.Fill(dt); //(dt.Rows.Count == 1) if (dt.Rows[0][0].ToString()=="1") { this.Hide(); Form2 f = new Form2(); f.Show(); } else { MessageBox.Show("Пожалуйста введите логин или пароль"); }
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Вячеслав\Desktop\БД\WindowsFormsApplication1\WindowsFormsApplication1\Database1.mdf;Integrated Security=True");
SqlDataAdapter sda = new SqlDataAdapter("Select Count(*) from User where Login='"+textBox1.Text+"' and Password='"+textBox2.Text+"'", con );
DataTable dt = new DataTable();
sda.Fill(dt);
//(dt.Rows.Count == 1)
if (dt.Rows[0][0].ToString()=="1")
{
this.Hide();
Form2 f = new Form2();
f.Show();
}
else
{
MessageBox.Show("Пожалуйста введите логин или пароль");
}
}