I need to retrieve certain field of information about a user once they've logged in I am able to log the user in successfully using an access database, which stores their usernames and passwords. But i am having trouble retrieving information about that user
once they have logged in, For instance name, surname, User_level If anyone could help i would be so grateful Thanks
You need to show some code. If you are determining the username and password is correct, then it should not be a great jump from that code to code that gets the other information.
heres my code for the logging in process this works fine and redirects the user back to the page that they were not allowed to access(specified in the web.config file). I need to work out how to retain more info about that user throughout different pages within
my web site. Protected Sub Login_OnClick(Sender As Object, E As EventArgs) Dim SqlStmt As String = "SELECT COUNT(*) FROM LogIn WHERE Email='" & _ UserName.Text.Trim() & "' " & _ "AND Pass = '" & _ Password.Text.Trim() & "'" Dim con As OleDbConnection = New
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Gareth\My Documents\Year 3\Project\Actual Project\Student.MDB;") Dim cmd As OleDbCommand = New OleDbCommand(SqlStmt, con) Dim reader As OleDbDataReader = Nothing con.Open()
reader = cmd.ExecuteReader() While reader.Read() If Int32.Parse(reader(0).ToString()) >= 1 Then FormsAuthentication.RedirectFromLoginPage(UserName.Text, PersistCookie.Checked) 'HttpContext.Current.Response.Redirect("/topiclearn.aspx") Else ErrorMsg.Text =
"
User not found, or password is incorrct - try again!
" End If End While con.Close() End Sub Thanks, Gareth
Protected Sub Login_OnClick(Sender As Object, E As EventArgs)
Dim SqlStmt As String = "SELECT [Name],Surname,User_Level FROM LogIn WHERE Email='" & _
UserName.Text.Trim() & "' " & _
"AND Pass = '" & _
Password.Text.Trim() & "'"
Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Gareth\My Documents\Year 3\Project\Actual Project\Student.MDB;")
Dim cmd As OleDbCommand = New OleDbCommand(SqlStmt, con)
Dim reader As OleDbDataReader = Nothing
con.Open()
reader = cmd.ExecuteReader()
If reader.Read() then
Dim name as string
name=reader("Name").ToString()
' get others as well...
' Close here as well, since Redirect will cause balance of code not to be executed.
con.Close()
FormsAuthentication.RedirectFromLoginPage(UserName.Text, PersistCookie.Checked)
'HttpContext.Current.Response.Redirect("/topiclearn.aspx")
Else
ErrorMsg.Text = "
User not found, or password is incorrct - try again!
Floydy
Member
55 Points
11 Posts
how do u retrieve information from a user once they've logged in
Apr 16, 2004 01:14 PM|LINK
douglas.reil...
All-Star
23315 Points
4647 Posts
Re: how do u retrieve information from a user once they've logged in
Apr 16, 2004 01:28 PM|LINK
Programming Microsoft Web Forms
My Blog
Floydy
Member
55 Points
11 Posts
Re: how do u retrieve information from a user once they've logged in
Apr 16, 2004 04:34 PM|LINK
User not found, or password is incorrct - try again!
" End If End While con.Close() End Sub Thanks, Garethdouglas.reil...
All-Star
23315 Points
4647 Posts
Re: how do u retrieve information from a user once they've logged in
Apr 17, 2004 01:32 AM|LINK
Protected Sub Login_OnClick(Sender As Object, E As EventArgs) Dim SqlStmt As String = "SELECT [Name],Surname,User_Level FROM LogIn WHERE Email='" & _ UserName.Text.Trim() & "' " & _ "AND Pass = '" & _ Password.Text.Trim() & "'" Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Gareth\My Documents\Year 3\Project\Actual Project\Student.MDB;") Dim cmd As OleDbCommand = New OleDbCommand(SqlStmt, con) Dim reader As OleDbDataReader = Nothing con.Open() reader = cmd.ExecuteReader() If reader.Read() then Dim name as string name=reader("Name").ToString() ' get others as well... ' Close here as well, since Redirect will cause balance of code not to be executed. con.Close() FormsAuthentication.RedirectFromLoginPage(UserName.Text, PersistCookie.Checked) 'HttpContext.Current.Response.Redirect("/topiclearn.aspx") Else ErrorMsg.Text = "User not found, or password is incorrct - try again!
" End If con.Close() End SubProgramming Microsoft Web Forms
My Blog
Floydy
Member
55 Points
11 Posts
Re: how do u retrieve information from a user once they've logged in
Apr 17, 2004 11:06 AM|LINK