B
bj
I was perusing groups.Google.com and found a couple of articles for parsing
out a CSV file into an ADO.Net dataset. Although I haven't tried it yet,
the following example seems the most straight forward:
Dim TextConnectionString As String
TextConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & "c:\TestData" & ";" & _
"Extended Properties=""Text;HDR=NO;"""
Dim TextConn As New
System.Data.OleDb.OleDbConnection(TextConnectionString)
TextConn.Open()
Dim da As New System.Data.OleDb.OleDbDataAdapter("Select * from
test.csv", TextConn)
Dim ds As DataSet = New DataSet("CSVFiles")
da.Fill(ds, "TestFile")
Dim dt As DataTable
dt = ds.Tables("tableName1")
DataGrid1.SetDataBinding(ds, "tableName1")
Dim drCurrentCol As DataColumn
For Each drCurrentCol In dt.Columns
Console.WriteLine(drCurrentCol.ColumnName)
Next
Dim drCurrent As DataRow
For Each drCurrent In dt.Rows
Console.WriteLine(drCurrent(0).ToString)
Console.WriteLine(drCurrent(1).ToString)
Next
'...
'...
'...
TextConn.Close()
I need more examples or a better explanation of ADO.Net Datasets. This is
what I am trying to do:
1) Load a CSV file that contains 5 columns into a dataset table
Customer Name, Form Name, Product, File Name, DateTime
2) Each row has to be sorted (order by) Customer Name, Form Name.
3) I then have to find each row where Customer Name and Form Name are
duplicated
If I could get just that much done, 70% of the processing would be done.
Can a dataset (Dataset - Represents an in-memory cache of data) table be
used like a SQL data table?
I control the creation of the CSV file, should I just create an XML file
instead?
Thanks in advance
BJ
out a CSV file into an ADO.Net dataset. Although I haven't tried it yet,
the following example seems the most straight forward:
Dim TextConnectionString As String
TextConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & "c:\TestData" & ";" & _
"Extended Properties=""Text;HDR=NO;"""
Dim TextConn As New
System.Data.OleDb.OleDbConnection(TextConnectionString)
TextConn.Open()
Dim da As New System.Data.OleDb.OleDbDataAdapter("Select * from
test.csv", TextConn)
Dim ds As DataSet = New DataSet("CSVFiles")
da.Fill(ds, "TestFile")
Dim dt As DataTable
dt = ds.Tables("tableName1")
DataGrid1.SetDataBinding(ds, "tableName1")
Dim drCurrentCol As DataColumn
For Each drCurrentCol In dt.Columns
Console.WriteLine(drCurrentCol.ColumnName)
Next
Dim drCurrent As DataRow
For Each drCurrent In dt.Rows
Console.WriteLine(drCurrent(0).ToString)
Console.WriteLine(drCurrent(1).ToString)
Next
'...
'...
'...
TextConn.Close()
I need more examples or a better explanation of ADO.Net Datasets. This is
what I am trying to do:
1) Load a CSV file that contains 5 columns into a dataset table
Customer Name, Form Name, Product, File Name, DateTime
2) Each row has to be sorted (order by) Customer Name, Form Name.
3) I then have to find each row where Customer Name and Form Name are
duplicated
If I could get just that much done, 70% of the processing would be done.
Can a dataset (Dataset - Represents an in-memory cache of data) table be
used like a SQL data table?
I control the creation of the CSV file, should I just create an XML file
instead?
Thanks in advance
BJ