Hi. I am writing an application and I have two forms that both read from/write to a database. They are both bound and contain TableAdapters, BindingNavigators, and BindingSources. Both have controls that were dragged and dropped from the Data Sources pane. One is kind of a setup/maintenance form where the user inputs things such as surgeons, reasons for surgery being cancelled, etc. The other form is where the user enters the actual case data. I started with the setup form because it wasn't as complex. It is working perfectly. I set the Input form up the same way and even used basically the same query structure, however it does nothing. I've tested the queries inside the database itself and they work fine, so I know they are not the problem. The only thing is the update code for each form is nearly identical also, so I'm really not sure where to go from here.
Here is the working code:
Here is the code that doesn't work:
(All of the variables for the latter are defined in another part of the update procedure.)
Is there a difference that I'm overlooking or something? Everytime it runs through it acts like it updates fine, but no changes are ever made to the table. I've agonized over this for days and any help anyone could provide would be huge. Thanks!
Here is the working code:
Code:
Try
Me.Validate()
Me.SurgeonBindingSource.EndEdit()
Try
Me.SurgeonTableAdapter.Update(Me.CaseInputDataSet.Surgeon)
Catch
'reads the value from the cbobox and returns the index
Dim tmpInputSpec as String = cboSetupSurgeonSpec.Text
Dim tblTempSpec as DataTable = Me.SpecialtyTableAdapter.GetDataBy4(tmpInputSpec)
Dim rowSpec as DataRow
Dim tmpRow as String
rowSpec = tblTempSpec.Rows(0) 'returns only 1 row
tmpRow = rowSpec.Item(0) 'returns only 1 column
Me.SurgeonTableAdapter.EditQuery(txtSetupSurgeonName.Text,Val(tmpRow),Val(txtSetupSurgeonID.Text))
Me.CaseInputDataSet.AcceptChanges()
End Try
MsgBox("Update Successful",MsgBoxStyle.OkOnly)
Catch ex as Exception
MsgBox("Update Failed",MsgBoxStyle.Critical)
End Try
Here is the code that doesn't work:
Code:
Try
Me.Validate()
Me.CaseInputBindingSource.EndEdit()
Try
Me.CaseInputTableAdapter.Update(Me.CaseInputDataSet.CaseInput)
Catch
Me.CaseInputTableAdapter.EditQuery(txtInputAcct.Text, cboInputOR.Text, blFirst,
blCancelled, intCancel, intSurgeon, cboInputAddOn.Text, dateSched, dateTimeIn, dateCaseStart, _
dateCaseEnd, dateTimeOut, intDelay, blHoliday, lngTotalTime, lngGap, lngTO, lngDelay, _
Val(txtInputID.Text))
Me.CaseInputDataSet.AcceptChanges()
End Try
MsgBox("Update Successful",MsgBoxStyle.OkOnly)
Catch ex as Exception
MsgBox("Update Failed. " & Err.Description, MsgBoxStyle.Critical)
End Try
(All of the variables for the latter are defined in another part of the update procedure.)
Is there a difference that I'm overlooking or something? Everytime it runs through it acts like it updates fine, but no changes are ever made to the table. I've agonized over this for days and any help anyone could provide would be huge. Thanks!