Advertisement
Guest User

Untitled

a guest
Aug 20th, 2014
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. Protected Sub btnSubmit_Click(sender As Object, e As System.EventArgs) Handles btnSubmit.Click
  2. If Page.IsValid Then
  3. ' check for username & password in the database
  4. Dim conn As New SqlConnection("Data Source=.sqlexpress;Initial Catalog=LoginDB;Integrated Security=True")
  5.  
  6. ' Get the row corresponding the given username and password
  7. Dim strSQL As String = "Select * From Users Where Username='" + txtUname.Text + "' and Password = '" + txtPassword.Text + "'"
  8.  
  9. Dim dsc As New SqlClient.SqlCommand(strSQL, conn)
  10.  
  11. ' Fill the dataset
  12. Dim ds As New DataSet()
  13. dsc.sqlclient.sqlcommand(ds, "Users")
  14.  
  15. ' if there no entry then the user is invalid
  16. If ds.Tables("Users").Rows.Count = 0 Then
  17. Response.Redirect("Default.aspx")
  18. Else
  19. Response.Redirect("login.aspx")
  20. End If
  21. End If
  22. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement