Murray Brown
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.DestinationTab leName = oTableName
sqlBulkCopy.BulkCopyTimeou t = 0 'Indefinite when zero
For k As Integer = 0 To UBound(arrSplitColumns)
oColumn = arrSplitColumns(k)
sqlBulkCopy.ColumnMappings .Add(oColu mn, oColumn)
Next
con.Open()
sqlBulkCopy.WriteToServer( dtExcelDat a)
con.Close()
End Using
End Using
End Using
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.DestinationTab
sqlBulkCopy.BulkCopyTimeou
For k As Integer = 0 To UBound(arrSplitColumns)
oColumn = arrSplitColumns(k)
sqlBulkCopy.ColumnMappings
Next
con.Open()
sqlBulkCopy.WriteToServer(
con.Close()
End Using
End Using
End Using
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER