mahmud_uk

mahmud_uk

  • NA
  • 48
  • 0

Authenticate users

Aug 6 2004 9:24 AM
Hi guys, I have two forms, form1 and form2. I also have this login page written in C# in form1. I'm trying to authenticate users through SQL database, if authenticated they will login to form 2, if not an error message should pop up and not allow form2 to open. Also after authentication is sucessfull, form1 should close and form2 should stay open. Here's the code: da.Open(); SqlCommand thisCommand = da.CreateCommand(); String sQuery = "SELECT * FROM License WHERE Name = '"+ textBox1.Text +"' AND LicenseID = '"+ textBox2.Text +"'"; SqlCommand cmd = new SqlCommand(sQuery, da); SqlDataReader dr = cmd.ExecuteReader(); Form2 frm = new Form2(); //if (dr.Tables["License"].Rows.Count == 0) //MessageBox.Show("Incorrect UserName and/or ID, Try again!"); da.Close(); frm.Show(); I'm stuck on authentication and closing the form1, can someone direct me where i have gone wrong. Thanks, Mac

Answers (4)