Insert from DataAdapter table

G

Guest

Is it possible to use a DataAdapter table to perform an insert.
The DataAdapter table would be filled with data from an excel sheet and I would want to insert this data into a Sql Server table.

Example --
cmdInsert = New SqlCommand("Insert into authors select * from DataAdapter(table)")
conPubs.Open()
cmdInsert.ExecuteNonQuery()
 
J

Jamie Collins

You may be able to do this without a dataset:

Using SQL Server provider:

Insert into authors
select * from
OPENDATASOURCE(
'Microsoft.Jet.OLEDB.4.0',
'Data Source=C:\MyWorkbook.xls;Extended Properties=Excel 8.0'
)...Table

Using Jet provider:

Insert into
[ODBC;Driver={SQL Server};
SERVER=MYSERVER;
DATABASE=pubs;
UID=****;Pwd=****;].authors
select * from table

Jamie.

--
 

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