text and dataset

M

Myo Zaw

hi,
can i update/insert my database by reading the data from text file with
dataset. or if you have a better and faster way please share me. cause my
database has more than two million records and text file has more than
20,000 lines. :(

thanks in advance,
myo zaw
 
N

Nicholas Paldino [.NET/C# MVP]

Myo,

Assuming you want to just add records from the text file to the data
set, what you could do is first create the data set in such a way that it
matches the schema of your database table.

Once you do that, you can create new rows in your data table, the values
of which you get from parsing your text file (or, if you are lucky and it is
a delimited file of some kind, you use the data provider for text in OLE DB
through the System.Data.OleDb namespace).

Once you have your data table populated, you can create a data adapter
which has the InsertCommand set to a command which will insert the new
records. You then pass the data set to the adapter, and the rows should be
in your table.

Hope this helps.
 
M

Myo Zaw

Nicholas,
Can it also solve the update parts. If not how can i do that.

thanks,
Myo

Nicholas Paldino said:
Myo,

Assuming you want to just add records from the text file to the data
set, what you could do is first create the data set in such a way that it
matches the schema of your database table.

Once you do that, you can create new rows in your data table, the
values of which you get from parsing your text file (or, if you are lucky
and it is a delimited file of some kind, you use the data provider for
text in OLE DB through the System.Data.OleDb namespace).

Once you have your data table populated, you can create a data adapter
which has the InsertCommand set to a command which will insert the new
records. You then pass the data set to the adapter, and the rows should
be in your table.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Myo Zaw said:
hi,
can i update/insert my database by reading the data from text file
with dataset. or if you have a better and faster way please share me.
cause my database has more than two million records and text file has
more than 20,000 lines. :(

thanks in advance,
myo zaw
 

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