Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

VB.net SQL Bulk Copy Add new rows

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
ASKER CERTIFIED SOLUTION
Avatar of Pratima
Pratima
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Murray Brown

ASKER

Thanks