,我发现了以下错误:登录名和密码程序
An unhandled exception of type 'System.IndexOutOfRangeException' occurred in System.Data.dll Additional information: There is no row at position 0.
我已经贴上我的代码,我不能弄清楚为什么我收到此错误信息。
我知道这是一个非常基本的程序,但我只是在学习。 :)
SqlConnection con = new SqlConnection(@"Data Source=B70143272PC4;Initial Catalog=TestDB1;Integrated Security=True");
SqlDataAdapter sda = new SqlDataAdapter("select employeeid,username, password from Employeeinfo where [UserName] = '" + textBox1+ "' and [Password] = '" +textBox2.Text+"'", con);
DataTable dt = new DataTable();
sda.Fill(dt);
if (dt.Rows[0][0].ToString() == "1")
{
this.Hide();
Form2 ff = new Form2();
ff.Show();
}
else
{
MessageBox.Show("Please check your Username and Passowrd");
}