CSV Confusion...

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
 
C

Cor

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
 
P

Paul Clement

¤ 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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top