hie guys,
a great supportive sites i have ever seen,
i am facing a simple issue with my login windows form, which i have created, it works fine no issue, but now i want that after successful login user should be automatically redirect to home screen (windows forms) but unfortunaterly i am not finding any solution for this , now what shoud i use and the login form should automatically close after redirettion. pleaase help me . .
private void button_Login_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Documents and Settings\jumbo\My Documents\Visual Studio 2010\Projects\testingdatabase\testingdatabase\Database1.mdf;Integrated Security=True;User Instance=True");
//SqlConnection con = Program.Getconnection;
//SqlConnection con = Program.Getconnection;
//SqlConnection con = Program.con;
//SqlDataReader dr = null;
//try
//{
SqlCommand cmd = new SqlCommand("select * from Login WHERE Username = '" + txtUsername.Text +"' AND Password = '" + txtPassword.Text + "'");
cmd.Connection = conn;
conn.Open();
//dr = cmd.ExecuteReader();
SqlDataReader re = cmd.ExecuteReader();
if (re.Read())
{
MessageBox.Show("login success");
}
else
MessageBox.Show("inavlid username and password");
}
//catch (Exception ex)
//{
//MessageBox.Show(ex.Message);
// }
}
}