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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting key names from DB results

Status
Not open for further replies.

Crundy

Programmer
Jul 20, 2001
305
GB
Hello,
I'm ripping info out of a database and I want to loop through all the field names in each record replacing ' with '', but I don't seem to be able to get the key names into an array. I've tried this:

Set Conn = server.CreateObject ("ADODB.Connection")
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & dbpath & ";"

set RS=Conn.execute("select * from depts")

do until RS.EOF
for each keyname in RS.keys
RS(keyname) = Replace(RS(keyname), "'", "''", 1, -1, 1)
next

'Do some stuff with the row here
loop

but I get an error saying "Object does not support this property or method 'RS.KEYS'"

I've tried looping though as an array as well, but that didn't work. Can anyone help? C:\DOS:>
C:\DOS:>RUN
RUN DOS RUN!!
 
crundy,

In your loop, change to this:

do until RS.EOF
RS(keyname) = Replace(RS(keyname), "'", "''", 1, -1, 1)
' Do some stuff with the row here
rs.update
rs.movenext
loop

Cheers;
fengshui_1998


 
The problem isn't the update, it's getting the key names and using them.

Don't worry about it now, I just took the easy way out (replaced all the 's in the database itself!!) C:\DOS:>
C:\DOS:>RUN
RUN DOS RUN!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top