Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. Session["UserName"] = usernameTextBox.Text;
  2. Session["Password"] = passwordTextBox.Text;
  3. SqlConnection con = new SqlConnection();
  4. con.ConnectionString = "Data Source=itksqlexp8; ; Initial Catalog=mmartza_ConservationSchool;Integrated Security=True;Pooling=False";
  5.  
  6.  
  7. //Int32 verify;
  8. string query1 = "Select * from users where username='" + usernameTextBox.Text + "' and password='" + passwordTextBox.Text + "' ";
  9. // SqlCommand cmd1 = new SqlCommand(query1, con);
  10. System.Data.SqlClient.SqlCommand comm = new System.Data.SqlClient.SqlCommand(query1, con);
  11.  
  12. // create a sqldatabase reader which will execute the above command to get the values from sqldatabase
  13. System.Data.SqlClient.SqlDataReader reader;
  14.  
  15. // open a connection with sqldatabase
  16. con.Open();
  17.  
  18. // execute sql command and store a return values in reade
  19. reader = comm.ExecuteReader();
  20.  
  21. // check if reader hase any value then return true otherwise return false
  22. if (reader.Read())
  23. Server.Transfer("Homepage.aspx", true);
  24.  
  25. else
  26. errorLabel.Text = "Please enter a valid username and password or create a new account";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement