Ok, running into a problem with pulling a Zip code from a CSV file using ADO. Whats happening is that if the first set of zip codes are 5 digits long, the datatype is assigned as an integer for the whole field property in the recordset which wouldn’t be a problem if the following zip codes weren’t the 9 digit zip code with the dash (99999 vs 99999-9999). When these 9 digit zip codes are encountered, the field yields a null. So, I can only assumet that JET 4 takes a small sample of the data (first 3 records?) and assigns the datatype to that field. Ive tried setting the field type during runtime, but failed either because I don’t know what I am doing or its beyond my control.
A couple of note worthies:
1. I have control of the SQL statement that pulls the info (which uses a group by clause)
2. I have limited control before the data is pulled in.
3. The runtime language VB6 using ADO.
Any suggestions or pointers?
Yes, ADO does type coercion based on the first record. Dash ‘-‘ is an invalid character in an integer type, so it won’t parse them. You want the entire thing to be a string (Really, you do- zip codes are strings, not integers).
It might be worth it to preparse the data. Write a small program to read the CSV and add -0000 to the 5-digit records. Then all records will be 10 digits, with a -, and should be coerced to a string.