Record Sets

Discussion in 'ASP General' started by Shahid Juma, Jan 26, 2005.

  1. Shahid Juma

    Shahid Juma Guest

    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
     
    Shahid Juma, Jan 26, 2005
    #1
    1. Advertising

  2. Shahid Juma

    Rob Meade Guest

    "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.

    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
     
    Rob Meade, Jan 26, 2005
    #2
    1. Advertising

  3. Shahid Juma

    Hal Rosser Guest

    "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
     
    Hal Rosser, Jan 26, 2005
    #3
  4. Shahid Juma

    Shahid Juma Guest

    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

    "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
    >
    >
     
    Shahid Juma, Jan 27, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SnVzdGlu?=

    Retrieving Record Key while creating the record.

    =?Utf-8?B?SnVzdGlu?=, Oct 4, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    665
    =?Utf-8?B?SnVzdGlu?=
    Oct 5, 2004
  2. André
    Replies:
    0
    Views:
    3,783
    André
    Jun 25, 2006
  3. MRW
    Replies:
    0
    Views:
    400
  4. THurkmans
    Replies:
    2
    Views:
    624
  5. Replies:
    4
    Views:
    196
    McKirahan
    Sep 30, 2006
Loading...

Share This Page