bindingsource.addnew does not set dataset.has changes = true

  • Thread starter Thread starter RONATMOODYLAKE
  • Start date Start date
R

RONATMOODYLAKE

Guest
I am getting data from an Excel spreadsheet and attempting to add records to an access database. I have been successful programmatically adding records to other tables in the database with the method below. It doesnt work with this table.

Dim sqlConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & data_path
Dim sqlConnection As New OleDb.OleDbConnection(sqlConnectionString)
sqlConnection.Open()
ChecksTableAdapter.Connection = sqlConnection
ChecksBindingSource.DataSource = ChecksTableAdapter.GetData
ChecksBindingSource.AddNew()
ChecksBindingSource.Current("check_number") = "FWD"
xlCells = oXLSheet.Cells(first_row, DATE_COL + 1)
cell_text = CStr(xlCells.Value)
ChecksBindingSource.Current("check_date") = cell_text
ChecksBindingSource.Current("payee") = ""
ChecksBindingSource.Current("payment") = ""
ChecksBindingSource.Current("deposit") = ""
ChecksBindingSource.Current("balance") = initial_balance
ChecksBindingSource.Current("comment") = ""
ChecksBindingSource.Current("payment_value") = 0
ChecksBindingSource.Current("deposit_value") = 0
ChecksBindingSource.EndEdit()
If Me.ChecksDataSet.HasChanges Then
Try
Me.Validate()
Me.ChecksBindingSource.EndEdit()
Me.ChecksTableAdapter.Update(Me.ChecksDataSet.checks)
MsgBox("Update successful")
Catch ex As Exception
FindErrors()
MsgBox("Update failed")
End Try
End If


Me.ChecksDataSet.HasChanges never true

Where should I look now? An UpdateCommand has been added to the checksTableAdapter by the wizard.


RONATMOODYLAKE

Continue reading...
 
Back
Top