Reputation: 1629
In my C# code, I have get a DataTable from excel,It has somedata.Now I want to create a table in database using this DataTable ,and insert it's data to database. How could I do it? using SqlBulkCopy?
I want to write a method like this
///using DataTable dt to create Table and insert data to this created table
public bool CreateTable(string sqlconnectionstring,DataTable dt)
{
}
Upvotes: 0
Views: 46
Reputation: 542
INSERT INTO dbo.ImportTest
SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\ImportData.xls', [Sheet1$])
Upvotes: 1