Record Sets

S

Shahid Juma

Hi,

Is there a way for me to determing if a column exists in the table? ex. I
have RS("var"), where RS is a recordset. My code is dynamic but some tables
will have "var" while some won't.

Thanks for the help
Shahid
 
R

Rob Meade

...
Is there a way for me to determing if a column exists in the table? ex. I
have RS("var"), where RS is a recordset. My code is dynamic but some tables
will have "var" while some won't.

Hello Shahid,

You didn't mention which database you were using, it might not make any
difference, but with SQL Server you could query the system objects to find
out columns that are within a table, I believe you could also get the data
types and lengths.

This article might give you something you want in a very raw manner:

http://www.4guysfromrolla.com/webtech/112900-1.shtml

You could simply iterate through the rs.fields and check for the existance
of your field...

When you pop the variable after the RS you don't need the quotes either, so
you'd have:

RS(strField)

(I believe)..

Regards

Rob
 
H

Hal Rosser

Shahid Juma said:
Hi,

Is there a way for me to determing if a column exists in the table? ex. I
have RS("var"), where RS is a recordset. My code is dynamic but some tables
will have "var" while some won't.

Thanks for the help
Shahid

For x = 0 to RS.Fields.Count - 1
If RS.Fields(x).Name = strTheName Then
'code to execute if the the column exists
End If

Next
 
S

Shahid Juma

Thanks,

Is there a direct method that could check, ie. exists? Using what you have
below somehow makes my rest of the fields not output.

Shahid
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,999
Latest member
MakersCBDGummiesReview

Latest Threads

Top