Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

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

$
0
0

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 doesn't 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


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>