Solved

VB.net SQL Bulk Copy Add new rows

Posted on 2015-01-05
2
262 Views
Last Modified: 2015-01-06
Hi
The following code in my project uses the bulk copy class to upload a new data table created in Excel called "dtExcelData". I now have a different situation where I connect to a SQL database table using a data table
and add new rows to this data table. How do I alter the code below to commit these changes to a data table?


                    Using sqlBulkCopy As New SqlBulkCopy(con)

                        'Set the database table name
                        sqlBulkCopy.DestinationTableName = oTableName
                        sqlBulkCopy.BulkCopyTimeout = 0 'Indefinite when zero

                        For k As Integer = 0 To UBound(arrSplitColumns)
                            oColumn = arrSplitColumns(k)
                            sqlBulkCopy.ColumnMappings.Add(oColumn, oColumn)
                        Next


                        con.Open()

                        sqlBulkCopy.WriteToServer(dtExcelData)

                        con.Close()

                    End Using

                End Using

            End Using
0
Comment
Question by:murbro
2 Comments
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 500 total points
ID: 40533036
sqlBulkCopy.WriteToServer(dtExcelData)

will save data toserver
but you can do dedicated bulk copy operation intransaction if you want

check this link for more details

http://msdn.microsoft.com/en-us/library/tchktcdk(v=vs.110).aspx
0
 

Author Closing Comment

by:murbro
ID: 40533041
Thanks
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now