private void btnLogin_Click(object sender, EventArgs e) { string connectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Documents and Settings\\K-Ur\\My Documents\\Visual Studio 2008\\Projects\\WindowsFormsApplication2\\WindowsFormsApplication2\\IMS.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"; SqlConnection con = new SqlConnection(connectionString); con.Open(); DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter("SELECT UserName,Password " + "FROM LogIn " + "WHERE UserName = '******' AND Password = '******'", con); da.Fill(ds); int count = ds.Tables[0].Rows.Count; if (count == 0) { MessageBox.Show("Invalid UserID/Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); txtUserName.Text = ""; txtPassword.Text = ""; } else { MessageBox.Show("Successful Login", "Welcome", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); //txtUserName.Text = ""; //txtPassword.Text = ""; this.Hide(); if (txtUserName.Text == "admin") { Admin_Home ah = new Admin_Home(); ah.Show(); } else { Executive_Home eh = new Executive_Home(); eh.Show(); } } con.Close(); }
private void btnLogin_Click(object sender, EventArgs e) { string connectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Documents and Settings\\K-Ur\\My Documents\\Visual Studio 2008\\Projects\\WindowsFormsApplication2\\WindowsFormsApplication2\\IMS.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"; SqlConnection con = new SqlConnection(connectionString); con.Open(); DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter("SELECT UserName,Password " + "FROM LogIn " + "WHERE UserName = '******' AND Password = '******'", con); da.Fill(ds); int count = ds.Tables[0].Rows.Count; if (count == 0) { MessageBox.Show("Invalid UserID/Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); txtUserName.Text = ""; txtPassword.Text = ""; } else { MessageBox.Show("Successful Login", "Welcome", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); //txtUserName.Text = ""; //txtPassword.Text = ""; this.Hide(); if (txtUserName.Text == "admin") { Admin_Home ah = new Admin_Home(); ah.Show(); } else { Executive_Home eh = new Executive_Home(); eh.Show(); } } con.Close(); }