VB.NET Code behind:
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim dbconn As SqlConnection
Dim dbcommand As SqlDataAdapter
Dim dslogin As New DataSet
dbconn = New SqlConnection("Server=localhost;UID=sa;PWD=sa;database=websiteDemo")
dbconn.Open()
dbcommand = New SqlDataAdapter("Select UserID from " _
& "Login Where " _
& "Username = '" & TextBox1.Text _
& "' and Password = '" & TextBox2.Text _
& "'", dbconn)
dbcommand.Fill(dslogin, "Login")
If dslogin.Tables("Login").Rows.Count = 0 Then
Response.Write(dslogin.Tables("Login").Rows.Count = 0)
Label3.Text = "Username and Password Not Found.Please Try Again!"
Else
Session("UserID") = dslogin.Tables("Login").Rows(0).Item("UserID")
Session("Username") = TextBox1.Text
Response.Redirect("./Success.aspx")
End If
End Sub
i m getting : output as:
Username and Password Not Found.Please Try Again!"
instead i have that username in the database. Also i m inputting correct Username and Password.