Re: DataRowBuilder????

P

Pete Wright

Ok, I sense some confusion with the world of ADO.NET ;)

First up, if you have a comma delimited text file you can read that into a
DataSet quite easily, in principle anyway. But, you have a database now, so
let's work with that.

First thing you are going to want is a connection to the database. Now, I'm
going to assume that you have SQL Server database, but the same principles
apply, just use OleDb whereever you see me using Sql (ie SqlConnection
becomes OleDbConnection). You may need to change the connection string as
well - the bit used in creating the connection. Take a look at the MSDN help
with Visual Studio for pointers on this (Its late and I'm sitting on the
couch miles away from a book)

Ok - so creating a connection

Dim myConnection as SqlConnection = new SqlConnection("Data
Source=localhost;Initial catalog=mydatabase;Integrated Security=true")

With a connection created, you'll need a data adapter - some method of
getting information out of the database and into a dataset

Dim myAdapter as SqlDataAdapter = new SqlDataAdapter( myConnection, "Select
* from myTable");

Now all you need is a DataSet that the data adapter can fill. e.g

Dim myDataSet as DataSet = new DataSet();
myAdapter.Fill( myDataSet, "mytable");

At this point you'll have a single table in the dataset which you can get at
with

myDataSet.Tables("myTable")

and within the table you have rows that you can 'iterate' through with a
foreach loop. For example

Dim myRow as DataRow
for each myRow in myDataSet.Tables("myTable")
:
: Do something with myRow here
next


You should probably look at MSDN for ADO.NET tutorials to get up to speed
with all the terms and how all the objects etc work together.

Hope that helps,

--
Peter Wright
Author of ADO.NET Novice To Pro, from Apress Inc.


_____________________________
 
K

Kathleen Dollard

Rick,

If Access has a bulk load, you might want to do that. If not

Open the comma delimted file as a string. I assume it is CR/LF delimted
between records, so you can use a ReadLine method of teh StreamReader object

You can use [string].split with a comma character to put the data into an
array

You can copy from the array to you dataset

You can run your report.

What you are planning is a fine design, you're just going to have a lot of
network traffic without the batch upload.
 

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