لدي كود Login ..
Sub btnLogin_OnClick(Src As Object, E As EventArgs)
If Page.IsValid Then
Dim MyAddress As String
Dim MyConn As OleDbConnection
Dim MySQL As String
Dim MyRs As String
Dim MyCount As OleDbCommand
Dim MyPassword As OleDbCommand
Dim IntUserCount As Integer
Dim strPassword As String
If Request.QueryString("ReturnUrl") = "" Then
MyAddress = "default.aspx"
Else
MyAddress = Request.QueryString("ReturnUrl")
End If
MySQL = "SELECT COUNT(*) FROM Users WHERE Username = '" & txtUsername.Text & "'"
MyRs = "SELECT Password FROM Users Where Username = '" & txtUsername.Text & "'"
MyConn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("Data/dbUsers.mdb") & ";")
MyCount = New OleDbCommand(MySQL, MyConn)
MyPassword = New OleDbCommand(MyRs, MyConn)
MyConn.Open()
IntUserCount = MyCount.ExecuteScalar()
strPassword = MyPassword.ExecuteScalar()
MyConn.Close()
If IntUserCount > 0 Then
If strPassword = txtPassword.Text Then
FormsAuthentication.SetAuthCookie(txtUsername.Text, True)
Response.Redirect(MyAddress)
Else
lblMsg.Text = "Invalid Password..."
End If
Else
lblMsg.Text = "Invalid Username..."
End If
Else
Exit Sub
End If
End Subوبعد عملية تسجيل دخول يتجه لصفحة Default.aspx والتي تتضمن الكود ..
Sub Page_Load()
UserAuth.Text = User.Identity.Name
End Sub
Sub doLogout(Src As Object, E As EventArgs)
FormsAuthentication.SignOut()
Response.Redirect("login.aspx")
End Subالمطلوب ..تخيل أن في صفحة Default.aspx أداة GridView وأريد ان أعرض فيها بيانات المستخدم User الذي سجل دخوله
