Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch Add

Status
Not open for further replies.

JustBarno

Programmer
Jun 21, 2004
46
US
What is the most efficent way in ADO.NET to add every row in a datatable to a table in SQL?

For example, I have a list of tasks in an excel spreadsheet. I load it into a datatable, and now want to enter each of those tasks into the Tasks table in my SQL server.

I know a few ways to do it now, but I'm new to .NET and figured I'd try and learn the "right" way.

Thanks!
 
The .NET way to do it would be to wire up a DataAdapter with an InsertCommand (loads of examples everywhere on the Internet), associate the DataTable and the DataAdapter, and fire away.

Personally, I like more control and would opt for iterating over the DataTable and building the commands manually and firing them directly over a SqlCommand object.

-paul

penny.gif
penny.gif

The answer to getting answered -- faq855-2992
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top