Vb.net code for Login page for a particular usertype
Following code is used to check whether entered login details matches and exists in the database and also it is checked whether user type is as specified.
Check code comments for more details.
Code Snippet:
Partial Class ContractorLogon
Inherits System.Web.UI.Page
'Login button click event is below.
Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
Dim sc As New SqlConnection
Dim scmd As New SqlCommand
Dim scmd1 As New SqlCommand
Dim dap As New SqlDataAdapter
Dim ds As New DataSet
Dim user As String
Dim currentCount As Integer = hitCounts(False)
sc.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("SiteSqlServer")
'following select statement is used to check whether entered user name and password exists in database and matches and also whether user belongs to the specified user type.
scmd1.CommandText = "select * from USER_ROLES where PASSWORD ='" & (TextBox2.Text).ToLower() & "' and USERNAME='" & (TextBox1.Text).ToLower() & "' and USER_TYPE='Contractor'"
scmd1.Connection = sc
sc.Open()
user = scmd1.ExecuteScalar
sc.Close()
'If query conditions are satisfied then current page will be redirected to another page called Contractorform.aspx
If Not user Is Nothing Then
Response.Redirect("ContractorForm.aspx")
'If query condition is not satisfied and number of wrong attempts is less than
3 then error message Invalid user name or password will be
displayed.
ElseIf user Is Nothing AndAlso currentCount <= 3 Then
Response.Write("<script >alert('Invalid username or password')</script>")
currentCount = hitCounts(True)
'If wrong attempts are greater than or equal to 3 then current page will be
redirected to an another error page.
If currentCount >= 3 Then Response.Redirect("Tenanterrorpage.aspx")
End If
End Sub
'Following function is used to count the number of wrong attempts used to login
Protected Shared Function hitCounts(ByVal blnCntToBeIncr As Boolean) As Integer
Static i As Integer = 0
If blnCntToBeIncr Then i += 1
Return i
End Function
End Class

Hi iam Swapna!This resource is not good i mean it is not understandable to begginers.pls change the terminology.