July 2, 2013 at 12:10 am
c# - Insert data from DataTable to database table
July 2, 2013 at 12:22 am
Please explain your question, it is very unclear. Please be more specific and give more information about your situation and what you want to do.
July 2, 2013 at 12:24 am
can you elaborate your question?.
July 2, 2013 at 1:11 am
ramanathan.raman88 (7/2/2013)
c# - Insert data from DataTable to database table
I see you have edited your original post, but it is still not telling us much. Do we need to guess what you want?
My guess: You have a C# application that connects to a database on a SQL instance. On the C# application you have a grid with data (from where???). You need to write the data from the grid (how many columns, rows; what type of data???) to one (or more????) tables in the database. You want us to give you the statement you need to use to get the data from the grid into the table(s).
If I'm wrong, please tell us the correct story :w00t:. If my guess is correct, why didn't you write this down in the first place :hehe:.
July 2, 2013 at 6:26 am
You can use a DataAdapter and call the update method, OR write a small loop to loop through the rows in the table and do an insert on each one using SQLConnection. Using the DataAdapter is easier but it essentially does the same thing behind the scenes.
The probability of survival is inversely proportional to the angle of arrival.
July 5, 2013 at 8:09 pm
The SqlBulkCopy class is the fastest way to load an ADO.NET DataTable to a SQL Server table.
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.aspx
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply