Guest User

Untitled

a guest
Nov 20th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. public static Boolean ValidateUser(string struser, string strpass)
  2. {
  3. // Establish connection information
  4. SqlConnection conn_string = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Data Source=137.145.169.3;Initial Catalog=SICI4266;Persist Security Info=True;User ID=SICI4266G3;Password=*******"].ConnectionString);
  5. // Establish SQL command
  6. SqlCommand sql_comm = new SqlCommand("SELECT count(userID) FROM HIEPA.HIEPA_USERS where UserName = @usuario and UserPassword = @contrasena ; ", conn_string);
  7. // Provide Parameter values
  8. sql_comm.Parameters.AddWithValue("@usuario", struser);
  9. sql_comm.Parameters.AddWithValue("@contrasena", strpass);
  10. // Open the connection
  11. conn_string.Open();
  12. // Execute the SQL command and assign the resulting value to an integer variable
  13. Int32 intUserCount = Convert.ToInt32(sql_comm.ExecuteScalar());
  14. // Close the connection
  15. conn_string.Close();
  16. // Evaluate the integer variable content; greater than cero is a valid combination
  17. if (intUserCount == 1)
  18. {
  19. return true;
  20. }
  21. else
  22. {
  23. return false;
  24. }
  25. }
Add Comment
Please, Sign In to add comment