inserting many records in 1 single connection

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

in VB.net (windows form):
the function is reading 2 colums x 1000 rows, from an excel file, loading
them in a datatable then add the datatable to a dataset.

How can I send this dataset to the database to insert all those records in a
table in one single connection ?

thanks
 
Zino,

Read your Excel file in a dataset using this kind of code (Sheet1 can be
another name)
\\\
Dim ConnectionString As String
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\test1\myExcel.xls;" & _
"Extended Properties=""Excel 8.0;HDR=NO"""
Dim Conn As New System.Data.OleDb.OleDbConnection(ConnectionString)
Dim da As New System.Data.OleDb.OleDbDataAdapter _
("Select * from [Sheet1$]", Conn)
Dim ds As New DataSet
da.Fill(ds, "Sheet1")
///

Than change the names of the columns in your dataset to the columns in your
database table, open a connection in your database, create a dataadapter and
do a fillschema.

http://msdn.microsoft.com/library/d...ystemdataidataadapterclassfillschematopic.asp

Than you can even use the commandbuilder (I am not sure of this so you
should try that and otherwise create your own updatecommand) and do an
update of that dataset in the database

I hope this helps?

Cor
 
thank you for your help.
I used the commandBuilder to send the dataSet to the database
 
Hi Zino,

Did you still have any concern on this issue, please feel free to post here?


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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

Back
Top