I have created a DataTable from a spreadsheet worksheet and want to UPDATE my SQL table, but am struggling. I cannot update the single table having a Primary Key with the changed column information. Should be easy and straight forward. The ShowResult(dataTable) depicts the correct DataTable information. (Using some DevExpress expressions)
' Create a data table with column names obtained from the first row in a range if it has headers.
' Column data types are obtained from cell value types of cells in the first data row of the worksheet range.
Dim dtpHExportDataTable As DataTable = worksheet.CreateDataTable(range, rangeHasHeaders)
' Create the exporter that obtains data from the specified range, ' 'skips header row if required and populates the specified data ' table.
Dim exporter As DataTableExporter = worksheet.CreateDataTableExporter(range,dtpHExportDataTable, rangeHasHeaders)
'A custom method that displays the resulting data table.
ShowResult(dtpHExportDataTable) 'Looks good!
'Now, my code to Update the "Result" column in my sql table with the datatable information
Dim cnSQL As SqlConnection = dbLIMS.GetLIMSConnection
Using adapter = New SqlDataAdapter("SELECT * FROM Analytical_Sample_Log_ResultsInfo", cnSQL)
Using New SqlCommandBuilder(adapter)