Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Aug 2002
    Location
    Leeds
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy defining fields which do not exist...

    Hi there,

    do you know of a way that you can tell asp to get data from a field in a database table, only if that field exists ?

    I'm creating some pages that look into an access db (defined as an odbc connection on the server in question) that holds links to some csv dumps of event logs. However, depending on the machine, the number of columns that are dumped varies. So if you create a page to view a file but, say, column 8 doesn't exist, the page crashes.

    I was thinking os creating variables first, and referring to those in the sql string instead of the field names themselves but, of course, it will just crash earlier, when it tried to define the variable.

    Can anyone help ???

    Thanks, in advance,
    Brad.

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    676
    Thanks
    1
    Thanked 0 Times in 0 Posts
    stu...
    just a checkout® your yahoo just a ccount®...n' ifin' thattt stuff would help??? let /me just a know®...k???

  • #3
    Registered User
    Join Date
    Aug 2002
    Location
    Leeds
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    sorry, didn't understand much of that.

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Posts
    676
    Thanks
    1
    Thanked 0 Times in 0 Posts
    brad...
    just a oppps®.../me thouuught thattt you were just a nother® forum member...aka stu...hehehe...
    just a sorry® n' donttt worrry 'bout it... n' /me just a posts® off playing the wellduh.wav® to herself...rotflmao!!!

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    Cincinnati, OH
    Posts
    545
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am not sure if there is a way to check if a column exists. I have had to import csv files and it was a pain. I ended up doing like this - Read the entire file into a variable split the variable into array,:

    arrFile = Split(fileIn.ReadAll(), Chr(13) & Chr(10))

    Read through the array to access each field and validate, add, or update.

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    allida's way is just fine - also you could just make sure you write something to each field, even if it doesn't exist - some garbage string?

    I'd rather do it allida's way personally though - I use a similar concept to read data INTO an array at times. It just makes sense!

    You might even save the stuff as pipe delimited, in other words surround each entry with a pipe (|) or something even weirder like |~| just to make sure noone entered a pipe on accident and split the string like that.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •