CSV Confusion...

  • Thread starter Thread starter Juan
  • Start date Start date
J

Juan

Hi All...

I'm having a bit of difficulty displaying results into a datagrid. My search
queries a .CVS file.

The Code is as follows:

Dim DS As System.Data.DataSet
Dim MyCommand As System.Data.OleDb.OleDbDataAdapter

Dim MyConnection As System.Data.OleDb.OleDbConnection

MyConnection = New
System.Data.OleDb.OleDbConnection(provider=Microsoft.Jet.OLEDB.4.0; data
source=C:\; Extended Properties='text;HDR=No;FMT=Delimited'")

MyCommand = New System.Data.OleDb.OleDbDataAdapter( select * from test.csv",
MyConnection)

DS = New System.Data.DataSet()

MyCommand.Fill(DS)

DataGrid1.SetDataBinding(DS, "test")

MyConnection.Close()



Why can't I display this in a datagrid?

Thank you so much for your contribution.

Juan
 
Hi Juan,

Try this,
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
path & ";Extended Properties=""Text;HDR=No;FMT=Delimited\"""

Your CSV has to be in your culture setting.

I hope this works?

Cor
 
¤ Hi All...
¤
¤ I'm having a bit of difficulty displaying results into a datagrid. My search
¤ queries a .CVS file.
¤
¤ The Code is as follows:
¤
¤ Dim DS As System.Data.DataSet
¤ Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
¤
¤ Dim MyConnection As System.Data.OleDb.OleDbConnection
¤
¤ MyConnection = New
¤ System.Data.OleDb.OleDbConnection(provider=Microsoft.Jet.OLEDB.4.0; data
¤ source=C:\; Extended Properties='text;HDR=No;FMT=Delimited'")
¤
¤ MyCommand = New System.Data.OleDb.OleDbDataAdapter( select * from test.csv",
¤ MyConnection)
¤
¤ DS = New System.Data.DataSet()
¤
¤ MyCommand.Fill(DS)
¤
¤ DataGrid1.SetDataBinding(DS, "test")
¤
¤ MyConnection.Close()
¤
¤
¤
¤ Why can't I display this in a datagrid?
¤
¤ Thank you so much for your contribution.

It isn't clear what type of problem you are having. Are you getting errors? Is the format incorrect?
What is the field delimiter?

Perhaps you could post a few lines from your text file.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Back
Top