Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.Configuration
Partial Class how_to_login_with_sql_server
Inherits System.Web.UI.Page
Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.Authenticate
Dim username As String
Dim pwd As String
Dim pName As String
username = Login1.UserName
pwd = Login1.Password
pName = ""
Dim strConn As String
strConn = WebConfigurationManager.ConnectionStrings("ConnectionASPX").ConnectionString
Dim Conn As New SqlConnection(strConn)
Conn.Open()
Dim sqlUserName As String
sqlUserName = "SELECT UserName,Password FROM UserName "
sqlUserName &= " WHERE (UserName = @UserName"
sqlUserName &= " AND Password = @Password)"
Dim com As New SqlCommand(sqlUserName, Conn)
com.Parameters.AddWithValue("@UserName", username)
com.Parameters.AddWithValue("@Password", pwd)
Dim CurrentName As String
CurrentName = CStr(com.ExecuteScalar)
If CurrentName <> "" Then
Session("UserAuthentication") = username
Response.Redirect("how-to-StartPage.aspx")
Else
Session("UserAuthentication") = ""
End If
End Sub
End Class
ref from this link:
http://www.aspxcode.net/free-asp-net-login-source-code.aspx?Topics=How%20to%20Login%20With%20SQL%20Server%20Database Thanks
SagarP
http://www.emanonsolutions.net
http://emanonsolutions.blogspot.com/
Suneel161, if this helps please login to Mark As Answer. | Alert Moderator