我正在使用Visual Studio 2010
作爲我的IDE並使用3210創建一個簡單的網站我不知道是否有可能,但是我可以使用會話顯示剛登錄到我的LoginForm的用戶名到其他表單?顯示用戶名使用會話(ASP.NET)
我不是不夠好理解,但誰能告訴我,這是包含在會話中值的正確方法?我怎樣才能顯示它的其它形式?
Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
Dim connect As String = "Provider=Microsoft.ACE.OleDb.12.0;" & _
"Data Source=C:\Users\cleanfuel\Documents\Visual Studio 2010\Projects\FinalProject4a2p\FinalProject4a2p\bin\DBFinalProject.accdb"
Dim query As String
query = "Select Count(*) From tblAccount Where Username = ? And UserPass = ?"
Dim result As Integer = 0
Using conn As New OleDbConnection(connect)
Using cmd As New OleDbCommand(query, conn)
cmd.Parameters.AddWithValue("", TxtUser.Text)
cmd.Parameters.AddWithValue("", txtPass.Text)
conn.Open()
result = DirectCast(cmd.ExecuteScalar(), Integer)
End Using
End Using
If result > 0 Then
Response.Redirect("Menus.aspx")
Session("User") = TxtUser.Text
Session("Pass") = txtPass.Text
Else
Response.Write("<td>")
Response.Write("<div align=""center"">")
Response.Write("<font color='white'>")
Response.Write("Unable to Login, Invalid Username or Password! </font>")
Response.Write("</div>")
Response.Write("</td>")
End If
End Sub
我認爲你應該先在會話存儲的用戶名,然後才重定向他menus.aspx – AMember 2013-02-18 07:46:20
我做到了,這是錯誤,我得到:「對象引用未設置爲對象的實例。」 – Danjor 2013-02-18 08:00:48