I am trying to build a login page in asp.net with sql as backend ,
when i enter the username and password and click the submit , nothing happens.. Please help
this is my *.aspx.vb file........
Imports System.Data.SqlClient
Imports System.Data
Partial Class login1
Inherits System.Web.UI.Page
Protected Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Protected Sub TextBox2_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim un As String
Dim _password As String
un = TextBox1.Text
'----
Dim myConn As New SqlConnection
myConn.ConnectionString = ConfigurationManager.ConnectionStrings("Team13ConnectionString").ToString
Dim myCommand As New SqlCommand
myCommand.Connection = myConn
myCommand.CommandType = Data.CommandType.Text
Dim MyQuery As String
MyQuery = "SELECT pwd FROM TUser WHERE UserId='" & un & "'"
myCommand.CommandText = MyQuery
'----
myCommand.Parameters.Add(un, SqlDbType.NVarChar, 50).Value = TextBox1.Text
'//use add with value to specify which object you want to use
Dim adapt As New SqlDataAdapter
adapt = New SqlDataAdapter(myCommand)
'//load data to datatable
Dim dt As New DataTable
myConn.Open()
adapt.Fill(dt)
Dim a As DataRow
'//get Password on Datatable
For Each a In dt.Rows
_password = a("pwd").ToString()
'//Check password
If (_password = TextBox2.Text) Then
Response.Redirect("services.aspx")
End If
Next
myConn.Close()
End Sub
End Class