i am building small login form and this issue showed up. I SQL server connected (i tried couple different connections aswell), table should be right, i don't see any issue in that.
I have tried already couple different SQL connections and new databases and tables.
private void BtnLogin_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=MYDESKTOP\MSSQLSERVER01;Integrated Security=True;Connect Timeout=30;Encrypt=False; TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False");
SqlDataAdapter sqa = new SqlDataAdapter ("SELECT COUNT (*) from LOGINFORM where USERNAME ='" + txtUsername.Text +"' and PASSWORD = '" + txtPassword.Text + "'", con);
DataTable dt = new DataTable();
sqa.Fill(dt);
if (dt.Rows[0][0].ToString() == "1")
{
this.Hide();
Form2 main = new Form2();
main.Show();
}
else
{
MessageBox.Show("Username/Password is incorrect. Please try again");
}
}
Expection unhandled invalid object name "LOGINFORM"