Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am trying to import a CSV into a recordset and there seems to be very little information on the web about working with CSV files. I want to import vaalues from the CSV and insert the values into a combobox. I can do it with MDB'sbut not with CSV's. Here is a snippet of the code:

 

' Creating connection and command sting

Dim conStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\HSDL

.CSV;Extended Properties=""text;HDR=Yes;FMT=Delimited"

Dim sqlStr As String = "SELECT DISTINCT CCY FROM HSDL.CSV"

' Create connection object

Dim conn As OleDb.OleDbConnection = New OleDb.OleDbConnection(conStr)

' Create data adapter object

Dim da As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(sqlStr, conn)

' Create a dataset object and fill with data using data adapter's Fill method

Dim ds As DataSet = New DataSet

da.Fill(ds, "HSDL.CSV")

 

' Attach dataset's DefaultView to the datagrid control

Dim dv As DataView = ds.Tables("HSDL0918.CSV").DefaultView

cboProd.DataSource = dv

cboProd.DisplayMember = "Date"

 

I'm think the problem lies somewhere in the fact that I didn't specify a table, I specified the file "HSDL.CSV" But I do not know what else I could use. Any ideas on how to get this to work?

 

Thanks

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...