PDA

View Full Version : defining fields which do not exist...


Brad
08-27-2002, 03:40 PM
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.

justame
08-27-2002, 05:15 PM
stu...
just a checkout® your yahoo just a ccount®...n' ifin' thattt stuff would help??? let /me just a know®...k???

Brad
08-27-2002, 05:20 PM
sorry, didn't understand much of that.

justame
08-27-2002, 05:42 PM
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!!!

allida77
08-27-2002, 05:57 PM
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.

whammy
08-28-2002, 01:57 AM
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.