I have two tables in my SQL Server database.
Table #1: Login_User
Columns
Unam, Pswd
Table #2 - Add_User
Columns
fName, lName, mobile, Eid, Unam, Pswd, Yob
Both tables have data.
My query is whenever user wanted to login, login credentials will be taken from either table1 or table2. I have written a SQL query with inner join as shown here:
string s = " select * from Login_User inner join Add_User on Login_User.Unam = Add_User.Unam where Login_User.Unam='" + txtUser.Text + "' and Login_User.Pswd='" + txtPswd.Text + "'";
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Product.mdf;Integrated Security=True;User Instance=True");
SqlDataAdapter da = new SqlDataAdapter(s, con);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows[0][0].ToString() == "1")
{
this.Hide();
Home hm = new Home();
hm.ShowDialog();
}
else
{
MessageBox.Show("Invalid User Name or Password!.");
}
I get an error
There is no row at position 0
Please help me