Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How to Store Data in Database using Data table Expand / Collapse
Author
Message
Posted Tuesday, July 2, 2013 12:10 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Monday, March 31, 2014 3:07 AM
Points: 99, Visits: 40
c# - Insert data from DataTable to database table
Post #1469300
Posted Tuesday, July 2, 2013 12:22 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 7:50 AM
Points: 2,262, Visits: 2,725
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.



** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **
Post #1469303
Posted Tuesday, July 2, 2013 12:24 AM
Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: 2 days ago @ 3:18 AM
Points: 672, Visits: 904
can you elaborate your question?.
Post #1469304
Posted Tuesday, July 2, 2013 1:11 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 7:50 AM
Points: 2,262, Visits: 2,725
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 . If my guess is correct, why didn't you write this down in the first place .


** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **
Post #1469320
Posted Tuesday, July 2, 2013 6:26 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, August 21, 2014 1:54 PM
Points: 1,432, Visits: 3,229
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.
Post #1469443
Posted Friday, July 5, 2013 8:09 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 9:23 AM
Points: 7,098, Visits: 12,605
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
Post #1470893
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse