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: Sunday, December 14, 2014 10:22 PM
Points: 99, Visits: 42
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: 2 days ago @ 6:08 AM
Points: 2,482, Visits: 3,028
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
Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Monday, December 8, 2014 5:37 AM
Points: 751, Visits: 967
can you elaborate your question?.
Post #1469304
Posted Tuesday, July 2, 2013 1:11 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: 2 days ago @ 6:08 AM
Points: 2,482, Visits: 3,028
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


UDP Broadcaster

UDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP Broadcaster

Group: General Forum Members
Last Login: Thursday, December 11, 2014 12:22 PM
Points: 1,446, Visits: 3,232
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: 2 days ago @ 1:25 AM
Points: 7,141, Visits: 12,767
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