0

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)
{

}
1

1 Answer 1

1
INSERT INTO dbo.ImportTest 
SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 
'Excel 8.0;Database=C:\ImportData.xls', [Sheet1$])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.