,我發現了以下錯誤:登錄名和密碼程序
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");
}