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 02, 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 02, 2013 12:22 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 7:59 AM
Points: 2,078, Visits: 2,410
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 02, 2013 12:24 AM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: 2 days ago @ 11:12 PM
Points: 603, Visits: 811
can you elaborate your question?.
Post #1469304
Posted Tuesday, July 02, 2013 1:11 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 7:59 AM
Points: 2,078, Visits: 2,410
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 02, 2013 6:26 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, March 04, 2014 7:44 AM
Points: 1,421, Visits: 3,220
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 05, 2013 8:09 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 9:25 AM
Points: 7,070, Visits: 12,523
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

Believe you can and you're halfway there. --Theodore Roosevelt

Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein

The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein

1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
Post #1470893
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse