Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Columns blank when importing CSV into recordset

Status
Not open for further replies.

petherin

Programmer
Dec 3, 2002
13
0
0
GB
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:

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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top