DataSet from/to CSV

  • Thread starter Thread starter Ondrej Sevecek
  • Start date Start date
O

Ondrej Sevecek

Hello,
is there any method to load DataSet from CSV file and on the other side to
place them to the file or some string?

Ondra.
 
You can walk through the rows and for each column, write the current rows
value and a comma except for the last row use a Carriage Return. You can do
the same reading it in. Two loops should do it for you in either direction.

However, if you can, examine DataSet.WriteXML and DataSet.ReadXML, it's much
cleaner and easier to use.

HTH,

Bill
 
¤ Hello,
¤ is there any method to load DataSet from CSV file and on the other side to
¤ place them to the file or some string?
¤

You can pull data in from a CSV file but you can't update the CSV file directly:

Private Sub ConnectToTextII_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles ConnectToTextII.Click

Dim ConnectionString As String
Dim SQLString As String

ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=e:\My Documents\TextFiles;Extended Properties=Text;"

SQLString = "Select * from TextFile.csv"

Dim ConnectionText As New OleDb.OleDbConnection()
ConnectionText = New OleDb.OleDbConnection()

ConnectionText.ConnectionString = ConnectionString

ConnectionText.Open()

Dim AdapterText As New OleDb.OleDbDataAdapter(SQLString, ConnectionText)

Dim DataSetText As New DataSet("TextFiles")
AdapterText.Fill(DataSetText, "TextFile")

DataGrid1.SetDataBinding(DataSetText, "TextFile")

ConnectionText.Close()

End Sub


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

Back
Top