Create table on DB along with data based on DataTable

c# sqlbulkcopy

Question

I've obtained an Excel DataTable with some data and used it in my C# app. I now want to use this DataTable to build a table in a database and put its data there. How was I able to achieve it? Using SQL Bulk Copy?

I want to create a technique similar to this.

///using DataTable dt to create Table and insert data to this created table
public bool CreateTable(string sqlconnectionstring,DataTable dt)
{

}
1
0
8/19/2015 2:44:07 AM

Popular Answer

INSERT INTO dbo.ImportTest 
SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 
'Excel 8.0;Database=C:\ImportData.xls', [Sheet1$])
1
8/19/2015 5:26:58 AM


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow