Partial Class Login
Inherits System.Web.UI.Page
Protected Sub Login1_Authenticate(sender As Object, e As AuthenticateEventArgs) Handles Login1.Authenticate
Dim username As String = Me.Login1.UserName.Trim().ToLower()
Dim password As String = Me.Login1.Password.Trim().ToLower()
Dim sds As SqlDataSource = New SqlDataSource("Data Source=.;Initial Catalog=mydata;User ID=sa;Password=Abcdefg1", "select count(*) from t_user where username = @username and userpass = @userpass")
sds.SelectParameters.Add("username", username)
sds.SelectParameters.Add("userpass", password)
Dim ie As IEnumerable = sds.Select(DataSourceSelectArguments.Empty)
Dim dv As System.Data.DataView = ie
Dim b As Boolean = dv(0)(0)
If b Then
Session("username") = username
Session("userpass") = password
Response.Redirect("~/Default.aspx")
Return
End If
Response.Write("登陆失败")
End Sub
End Class
http://localhost:49196/Login.aspx.vb再次改进
最新推荐文章于 2024-08-05 18:06:56 发布