The Error is because you haven’t open the connection before using it. First open the connection with the line “myCon.Open();” before using it in SqlDataAdapter and then use the ‘=’ operator in the select query of the where clause. you have missed that too in your query.
Your code should be
private void trydb() {
try
{
myCon.Open();
SqlDataAdapter MyDataAdapter = new SqlDataAdapter("select * from Logindata where username="" +Usertext.Text+ "" and password ='" +Passtext.Text+"' ;", myCon);
DataTable logicaldb = new DataTable();
MyDataAdapter.Fill(logicaldb);
//rest of your code here
}
catch
{
//exception code here
}
}
1
solved Need Help,There’s no error but can’t go to another form for this multi user form code(c#) [closed]