I'm doing a login form following this video here: https://www.youtube.com/watch?v=tcmmCcMs8yU
This is my code:
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\Hp\\Documents\\Data.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
SqlDataAdapter sda = new SqlDataAdapter("'Select Count (*) From Login Where Username='" + textBox1.Text + "'and Password='" + textBox2.Text + "''" ,con);
DataTable dt = new DataTable();
sda.Fill(dt);
if (dt.Rows[1][1].ToString() == "1")
{
this.Hide();
Main ss = new Main();
ss.Show();
}
else
{
MessageBox.Show("No Good");
}
}
My problem is on the sda.Fill(dt)
line, where it tells me I have an Instance Failure.
What can I do to fix it?
Thanks in advance!