Dim connStr As String = ConfigurationManager.ConnectionStrings(“MainConnStr”).ConnectionString
Dim sqlconnet As SqlConnection
Dim MyComm As SqlCommand
sqlconnet = New SqlConnection()
sqlconnet.ConnectionString = connStr
MyComm = New SqlCommand(“”, sqlconnet)
MyComm.CommandType = Data.CommandType.Text
MyComm.CommandText = “SELECT * FROM login WHERE (username ='” & txtUsername.Text & “‘) AND (password = ‘” & txtPassword.Text & “‘) ”
sqlconnet.Open()
Dim result As SqlDataReader = MyComm.ExecuteReader(Data.CommandBehavior.CloseConnection)
If result.HasRows = False Then
‘MsgBox(“login failed”)
‘Response.Write(“Fail”)
Lstatus.Text = “Your login or password doesn’t match. Login Fail”
Else
Session(“username”) = txtUsername.Text
‘MsgBox(“login success…!!!!”)
Response.Redirect(“success.aspx”)
‘Response.Write(“Success”)
End If
result.Close()