I have a similar problem to the one (which wasn't resolved) in thread183-883502, which I hope someone can clear up.
I am attempting to import a CSV into a table in VB:
The CSV file contains data as follows:
136 1100 260 Assign premium_base_total 0
136 1100 270 Assign premium_running 0
136 1100 280 Assign premium_running1 0
136 1100 300 Assign cover item:COVER
136 1100 310 Assign sum_insured item:SUM_INSURED1
136 1100 320 Assign engine_cc item:TEMP_ENGINECC
When the recordset is opened, the column with the 0's in the first three rows has a Type of adInteger. This means that when it gets to the rows containing
'item:COVER' etc, this column contains a Null.
I have tried to alter the Types of the fields using this code:
This doesn't work. I have also tried to fudge the issue by putting letters in the first few rows of the problem column, but the Type still comes out as
adInteger. can anyone help?
Kind regards
Peter Etherington
I am attempting to import a CSV into a table in VB:
Code:
Set objConn = New ADODB.Connection
objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sPath & _
";Extended Properties=""text;HDR=No;"""
objConn.Open
sSQL = "SELECT * FROM " & sFileName
Set objRS = New ADODB.Recordset
objRS.Open sSQL, objConn, adOpenStatic, adLockOptimistic, adCmdText
The CSV file contains data as follows:
136 1100 260 Assign premium_base_total 0
136 1100 270 Assign premium_running 0
136 1100 280 Assign premium_running1 0
136 1100 300 Assign cover item:COVER
136 1100 310 Assign sum_insured item:SUM_INSURED1
136 1100 320 Assign engine_cc item:TEMP_ENGINECC
When the recordset is opened, the column with the 0's in the first three rows has a Type of adInteger. This means that when it gets to the rows containing
'item:COVER' etc, this column contains a Null.
I have tried to alter the Types of the fields using this code:
Code:
objRS.Fields(5).Type = adVarChar
objRS.Fields.Update
This doesn't work. I have also tried to fudge the issue by putting letters in the first few rows of the problem column, but the Type still comes out as
adInteger. can anyone help?
Kind regards
Peter Etherington