Advertisements

"Shahid Juma" wrote ...
> 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.

Advertisements

"Shahid Juma" <> wrote in message
news:uKMBqP%...
> 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

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

"Hal Rosser" <> wrote in message
news:5nVJd.97373$...
>
> "Shahid Juma" <> wrote in message
> news:uKMBqP%...
> > 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
>
>

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!