PC Review


Reply
Thread Tools Rate Thread

CSV file into dataset

 
 
EMW
Guest
Posts: n/a
 
      21st Feb 2004
Hi,

I have a CSV file where the fields are inclosed in " and separated by ,

i.e.: "field1","field2","field3",..... etc.

Is it possible to fill a dataset in an easy way?
I can write my own methode to read it line by line, but then it would take
longer.

I know about the FAQ from www.syncfusion.com but when I use that, I only get
one column with everything.
Is there any other way?

thanks,
Eric


 
Reply With Quote
 
 
 
 
Cor
Guest
Posts: n/a
 
      22nd Feb 2004
Hi EMW

Here a sample, but the delimiter has to be in your culture setting.
(It goes about that FMT=Delimited\)
But that is very dependable on your culture settings, so you have to try.

Cor

\\\
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim file As String = "Test2.txt"
Dim path As String = "C:\Test1\"
Dim ds As New DataSet
Try
Dim f As System.IO.File
If f.Exists(path & file) Then
Dim ConStr As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
path & ";Extended Properties=""Text;HDR=No;FMT=Delimited\"""
Dim conn As New OleDb.OleDbConnection(ConStr)
Dim da As New OleDb.OleDbDataAdapter("Select * from " & _
file, conn)
da.Fill(ds, "TextFile")
End If
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
DataGrid1.DataSource = ds.Tables(0)
End Sub
I hope this helps a little bit?
///


 
Reply With Quote
 
Cor
Guest
Posts: n/a
 
      22nd Feb 2004
Hi EMW,

Here a sample, the point is the FMT=Delimeted\
The delimeter has to be in your culture settings way.
So with that you have to play

I hope this helps?

Cor
\\\
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim file As String = "Test2.txt"
Dim path As String = "C:\"
Dim ds As New DataSet
Try
Dim f As System.IO.File
If f.Exists(path & file) Then
Dim ConStr As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
path & ";Extended Properties=""Text;HDR=No;FMT=Delimited\"""
Dim conn As New OleDb.OleDbConnection(ConStr)
Dim da As New OleDb.OleDbDataAdapter("Select * from " & _
file, conn)
da.Fill(ds, "TextFile")
End If
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
DataGrid1.DataSource = ds.Tables(0)
End Sub
///



 
Reply With Quote
 
EMW
Guest
Posts: n/a
 
      22nd Feb 2004
Thanks, Cor!

"Cor" <(E-Mail Removed)> schreef in bericht
news:ewK8C9R%(E-Mail Removed)...
> Hi EMW,
>
> Here a sample, the point is the FMT=Delimeted\
> The delimeter has to be in your culture settings way.
> So with that you have to play
>
> I hope this helps?
>
> Cor
> \\\
> Private Sub Form1_Load(ByVal sender As Object, _
> ByVal e As System.EventArgs) Handles MyBase.Load
> Dim file As String = "Test2.txt"
> Dim path As String = "C:\"
> Dim ds As New DataSet
> Try
> Dim f As System.IO.File
> If f.Exists(path & file) Then
> Dim ConStr As String = _
> "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
> path & ";Extended Properties=""Text;HDR=No;FMT=Delimited\"""
> Dim conn As New OleDb.OleDbConnection(ConStr)
> Dim da As New OleDb.OleDbDataAdapter("Select * from " & _
> file, conn)
> da.Fill(ds, "TextFile")
> End If
> Catch ex As Exception
> MessageBox.Show(ex.ToString)
> End Try
> DataGrid1.DataSource = ds.Tables(0)
> End Sub
> ///
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataSet XSD file Dragon Microsoft C# .NET 1 24th Feb 2006 03:48 AM
Dataset to CSV file =?Utf-8?B?QnJpYW5ESA==?= Microsoft VB .NET 4 5th Aug 2005 06:02 PM
DataSet to MDB file =?Utf-8?B?UEpTaW1vbg==?= Microsoft VB .NET 5 21st Apr 2005 05:45 PM
How can I create an xsd file out of a Dataset class file? Babu Mannaravalappil Microsoft ADO .NET 1 4th Aug 2003 12:44 AM
Converting Dataset to a .IND file( dbaseIV index file) Hari Microsoft ADO .NET 0 12th Jul 2003 11:02 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:11 AM.