vtc127482 says:
createCmd1.ExecuteScalar();
if
(query1 ==
"1"
)
{
Form2 form =
new
Form2();
this
.Hide();
form.ShowDialog();
}
if
(query1 ==
"2"
)
{
Form3 form =
new
Form3();
this
.Hide();
form.ShowDialog();
}
Try to debug what you are checking exactly.
What you are doing here you already assigned the SQL select query and how can you match it as 1 or 2 it’s a simple SQL query.
You need to check the createCmdq.ExecuteScalar() value which is returning as 1 or 2. Store it in string variable and check.
string result = Convert.ToString(createCmd1.ExecuteScalar());
if (result =="1")
{
Form2 form = new Form2();
this.Hide();
form.ShowDialog();
}
else if (result == "2")
{
Form3 form = new Form3();
this.Hide();
form.ShowDialog();
}