0

I'm pretty stuck with this and don't know how to proceed. I am using ADODB to open a CSV file, this is working correctly however my text fields that exist in the CSV file are being opened as null fields, all of the number fields are correctly being set.

I open the CSV file like so;

Set adoOpen = Server.CreateObject("ADODB.Connection")
adoOpen.ConnectionString = "Driver={Microsoft Text Driver (*.txt; *.csv)};DBQ=C:/;Extensions=asc,csv,tab,txt;HDR=NO;Persist Security Info=False"
adoOpen.Open
Set rsOpenRS = Server.CreateObject("ADODB.Recordset")
sSQL = "SELECT * FROM `Import.csv`"
rsOpenRS.Open sSQL, adoCon

I also have a schema.ini file set up which tells it how I want my fields to be opened, like so

[Import.csv]
ColNameHeader=True
Format=CSVDelimited
Col1=MyTextField Memo 
Col2=MyNumberField Double
Col3=MyOtherNumberField Double

My data in my CSV file looks like this

MyTextField,MyNumberField,MyOtherNumberField
"Some text here",1,100

When I loop through my fields I would expect to see the following

MyTextField = Some text here
MyNumberField = 1
MyNumberField = 100

But instead what I get is this

MyTextField = 
MyNumberField = 1
MyNumberField = 100

It just ignores the text that is in that field, but the text is definitely there in the CVS file to start with.

I have tried using Text instead of Memo, this works, however it only brings back the first 255 characters, and some of my fields have more than this so they are getting truncated.

I hope somebody can help me out.

Cheers

David Coles
  • 45
  • 1
  • 11

1 Answers1

0

OK, so I changed my connection string from

Driver={Microsoft Text Driver (*.txt; *.csv)}

To

Provider=Microsoft.Jet.OLEDB.4.0

And now this works

David Coles
  • 45
  • 1
  • 11