Langston Posted October 14, 2003 Posted October 14, 2003 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 Quote
*Gurus* divil Posted October 14, 2003 *Gurus* Posted October 14, 2003 I think that when specifying the datasource, you specify the directory the file is in, not the file itself. You specify the file when opening the table. This is just from memory. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.