Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO recordset asp 1

Status
Not open for further replies.

alex5935

Programmer
Oct 24, 2007
13
US
I am having an issue with data access through the record set. When I am getting value from execution of the sql query with asp execute statement. The order of the selected data columns in the query is matters.
For example if my query “select firstname, lastname from users”, and I will try to access last name Rs(“last”) before accessing Rs(“firstname”) the values will be empty and will produce an error.
 
Pleaase show some code to clarify the situation.
 
query="Select firstname, lastname from users"


' if I am assigning lastname before firstname error will be
'produce and no data will be assigned
lastname=rs("lastname")
fistname=rs("fistname")

I don't have an exact source code now will get it later thanks
 
I've had this happen to me before, but it was a really long time ago.

I would suggest that you use ADO to connect to the database, and that you use an OLEDB connection string. If you do both of these things, you won't have any problems.

For help on the connection string, take a look at:



-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
So this error happens when you are only reading values out of the recordset, not when assigning values to fields in the recordset?

If the problem is reading values out of the recordset, does it happen if you reference the field by index rather than by name? (The index of the first field is zero)

For example:
query="Select firstname, lastname from users"
lastname=rs(1)
fistname=rs(0)
 
Thanks, I used this in the past. I have decided to get all the variables from the recordset in the asp variables like this
name=rs("name")
lname=rs("lname")
this will avoid error since I will not have to access it through rs object of ADO
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top