|
-
Dec 17th, 2002, 04:58 AM
#1
Thread Starter
Fanatic Member
Refering to fields in dataset
Below is a small chunk of code I use to validate a login form (usernam and password).
if userDS.Tables(0).rows.count > 0 then
'username and password exist
response.Clear()
response.redirect ("admin_main.aspx")
else
msg.text = "Invalid entry: Please try again"
end if
Once a user is verified, before the response.redirect I would like to create sessions for a variety of fields held in the dataset e.g fldUsername, fldPassword, fldTelephone.
Creating the sessions is not the problem but refering to the fields in the dataset is. I am to accustomed to classic ASP and am just learning the scary .net monster.
Can anyone help please?
Thankyou
-
Dec 17th, 2002, 10:01 AM
#2
Hyperactive Member
In this situation I'd use a DataReader, it's faster. But to answer your question, you could do this:
VB Code:
YourDataSet.Tables(0).Rows(0)("YourField").ToString()
... with a DataReader
VB Code:
Dim connString As String = "your connection string"
Dim cn As New SqlConnection(connString)
Dim cmdText As String = "Select * From Users Where ..."
Dim cmd As New SqlCommand(cmdText, cn)
Dim dr As SqlDataReader
cmd.Connection.Open()
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
If dr.Read() Then
Session("YourColumn") = dr("YourColumn").ToString()
Response.Redirect("yourPage.aspx")
Else
msg.Text = "Login Failed"
End If
-
Dec 18th, 2002, 04:51 AM
#3
Thread Starter
Fanatic Member
Thanks pvb.
I hope santa fills your sack.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|