Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB.net SQL Bulk Copy Add new rows

Posted on 2015-01-05
2
Medium Priority
?
283 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:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 2000 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:Murray Brown
ID: 40533041
Thanks
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

704 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