CSV file to DataSet

krispaks

Member
Joined
Jan 22, 2007
Messages
17
Programming Experience
1-3
hi i have this code which will try to get data from a csv file and then transfer it to a DataSet...

but im getting this exception when i try to open the connection

System.Data.OleDb.OleDbException = {"Could not find installable ISAM."}

need help... Tnx...

heres my code..

Private Function GetCSVFile(ByVal pathName As String, ByVal fileName As String) As DataSet
Using excelConn As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + pathName + ";Extended Properties=Text;HDR=Yes;FMT=Delimited")
Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM " + fileName, excelConn)
Dim excelAdpter As OleDbDataAdapter = New OleDbDataAdapter(cmd)
Try
excelConn.Open()
Catch ex As Exception
MsgBox(ex.Message)
End Try

Dim DS As DataSet = New DataSet
excelAdpter.Fill(DS)
excelConn.Close()
Return DS
End Using
End Function
 
Here's the connection string for a CSV file from connectionstrings.com:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\txtFilesFolder\;Extended Properties="text;HDR=Yes;FMT=Delimited"
Notice the double quotes around the entire Extended Properties value. Do you have double quotes around that value in your connection string?
 
tnx... got it already...

but i had this datagridview with the bindingsource...

i attached the dataset to the bindingsource and the binding source to the datagridview...

it didnt show the data... but when i used the old gridview... it worked...

why is this???

by the way to all VB.NET developers who might meet this problem in the future... here's the code i used for the connection string

Using excelConn As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + pathName + ";Extended Properties=""Text;HDR=Yes;FMT=Delimited""")
 
i attached the dataset to the bindingsource and the binding source to the datagridview...

it didnt show the data... but when i used the old gridview... it worked...

why is this???
Because you didn't do it properly with the DataGridView.
 

Latest posts

Back
Top