ADO INSERT to CSV file I get mismatch error
Newbie using ADO vba Excel to connect to a csv text file. I keep getting a type mismatch on the third field. Somehow ADO considers it to be a number field inspite of the fact that several of the column entries are Number/Alpha combos (eg 3a 2b etc). Any suggestions on how I can I avoid the "Type Mismatch" Error? Is there a way to assign types to the fields before the insert?
My code basically uses the sample code from page 401 of WROX Programmers Ref Excel 2002 ... to perform an ADO INSERT on a csv text file.
The 3rd field (batid) should be considered a text field but the âaa1â INSERT keeps generating a âtype mismatchâ error. It will only allow pure numbers.
Hereâs the code
'=======================
szConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & stDB & ";" & _
"Extended Properties=Text;"
Set objCommand = New ADODB.Command
objCommand.ActiveConnection = szConnect
objCommand.CommandText = "INSERT INTO " & FileName & "(Insid, insdate,batid) " & _
"VALUES('TestINS','1/1/2001','aa1');"
'=======================
Rene
Rene
|