|
-
Oct 24th, 2003, 09:20 AM
#1
Thread Starter
Fanatic Member
How to move to first record in my data reader
I have the following code....
VB Code:
commSQL.Connection = cn
commSQL.CommandText = "Select Stores From EmpStores_View Where " & _
"LoginName = '" & Request.Cookies("LoginName").Value & "' Order By Stores"
datRead = commSQL.ExecuteReader
strDistStores = ""
Do While datRead.Read
If strDistStores.Trim() = "" Then
strDistStores = "And (Location = '" & _
datRead.Item("Stores") & "'"
Else
strDistStores += " Or Location = '" & _
datRead.Item("Stores") & "'"
End If
Loop
strDistStores += ")"
Now when I'm done here, I want to bind this same datasource to a combo box.
What I don't know how to do is get to the first record after I run it through my loop.
Thanks
-
Oct 24th, 2003, 09:36 AM
#2
Fanatic Member
A datareader is a one shot deal. Once you go through it your done. I don't think you can read it again and you can't go backwards. You might want to return a dataset, or use the datareaders next results and do a second query in your stored procedure.
Also remember that your datareader is connected - so you want to close it as soon as possible to release the open connection to the database. It is also readonly.
-
Oct 24th, 2003, 09:43 AM
#3
Frenzied Member
Datareader is forward-only, read-only. If you are wanting to navigate through the records you'll need to use a DataSet.
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
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
|