ADO.Net Dataset questions

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
 
C

Cor Ligthert

1) Load a CSV file that contains 5 columns into a dataset table
Customer Name, Form Name, Product, File Name, DateTime

http://www.google.com/[email protected]

An answer on a message from Paul Clement
2) Each row has to be sorted (order by) Customer Name, Form Name.

Have a look at the dataview.sort
http://msdn.microsoft.com/library/d...tml/frlrfsystemdatadataviewclasssorttopic.asp

(Because of your next questions not the sort in the select)
3) I then have to find each row where Customer Name and Form Name are
duplicated
Use the dataview.rowfilter
http://msdn.microsoft.com/library/d...rlrfsystemdatadataviewclassrowfiltertopic.asp
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?
No although there is a Select which is a difficult method
I control the creation of the CSV file, should I just create an XML file
instead?
An XML file is not direct an XML dataset. When you have created a dataset
you can write it with dataset.writeXML(mypath), however do not mix that up
with an XML file, which can represent much more things.

I hope htis helps?

Cor
 
B

bj

I modified the SQL string a little to build a dataset table with all records
in the CSV file without a duplicate

SELCT F6 FROM Text.CSV WHERE F1 IN (SELECT F1 FROM Text.CSV GROUP BY F1, F2,
F3, HAVING Count(*) = 1)

Then I built one to identify all of the records that had a duplicate ...
HAVING Count(*) > 1

Thanks!!!
 

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