Unable to Save Record

  • Thread starter Thread starter gwboolean
  • Start date Start date
G

gwboolean

Guest
Working with these new methods are really trying my capabilities. It took me awhile, but I was able to figure out how to modify a record that fits the form I am working with..

The screen displays the selected record. I then edit those controls that allow it and then click the save button, which runs the method below.



Case "Edit"
If Not (ValidateData.ValidateInput()) Then Exit Sub
Try
Dim txtChangeRequest(18) As String
'Update record
txtChangeRequest(1) = lblChangeID.Text
txtChangeRequest(2) = lblProcessID.Text
txtChangeRequest(3) = txtTitle.Text
txtChangeRequest(4) = txtRevision.Text
txtChangeRequest(5) = txtProcess.Text
txtChangeRequest(6) = cmbManager.Text
txtChangeRequest(7) = cmbOwner.Text
txtChangeRequest(8) = cmbWhere.Text
txtChangeRequest(9) = chkQualify.Text
txtChangeRequest(10) = txtChanges.Text
txtChangeRequest(11) = txtReasons.Text
txtChangeRequest(12) = txtResults.Text
txtChangeRequest(13) = txtOpen.Text
txtChangeRequest(14) = txtSubmit.Text
txtChangeRequest(15) = txtApprove.Text
txtChangeRequest(16) = txtTrain.Text
txtChangeRequest(17) = txtEffective.Text
txtChangeRequest(18) = txtClose.Text
_MyBookMark = _MySQLManager.Position
_MySQLManager.EndCurrentEdit()
_MySQLtable.DefaultView.Sort = "chrChangeID"
_MySQLManager.Position = _MyBookMark
Dim ChangeAdapterCommand As New SqlCommandBuilder(_MySQLAdapter)
_MySQLAdapter.Update(_MySQLtable)
Dim ValidateData As New nspMasterBase.ChangeRequest
Dim EndConnect As New nspMasterBase.MasterBaseConnections
EndConnect.BreakConnMasterBase()
Catch ex As Exception
MessageBox.Show("Error saving record.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try

After the code is executed, the form is redisplayed showing the record as it now exists. So I figured that creating and saving a new record might be easier for me than getting here with modifying a record...….. But alas, here I am telling you my sad story.

Below is the method that I thought would create a new record, populated it with certain data and then allow the user to add certain other data. The code fully executes, but there is no record created. I am sure that I am missing just some small, but fundamental thing, but I cannot see what it is.

Case "New"
Try
_MyState = "View"
_MyBookMark = _MySQLManager.Position
_MySQLManager.AddNew()
Dim txtChangeRequest(18) As String
'Update record
txtChangeRequest(1) = lblChangeID.Text
txtChangeRequest(2) = lblProcessID.Text
txtChangeRequest(3) = txtTitle.Text
txtChangeRequest(4) = txtRevision.Text
txtChangeRequest(5) = txtProcess.Text
txtChangeRequest(6) = cmbManager.Text
txtChangeRequest(7) = cmbOwner.Text
txtChangeRequest(8) = cmbWhere.Text
txtChangeRequest(9) = chkQualify.Text
txtChangeRequest(10) = txtChanges.Text
txtChangeRequest(11) = txtReasons.Text
txtChangeRequest(12) = txtResults.Text
txtChangeRequest(13) = txtOpen.Text
txtChangeRequest(14) = txtSubmit.Text
txtChangeRequest(15) = txtApprove.Text
txtChangeRequest(16) = txtTrain.Text
txtChangeRequest(17) = txtEffective.Text
txtChangeRequest(18) = txtClose.Text
Dim NewRow As Integer
'UpDate Table
_MySQLAdapter.Update(_MySQLtable)
Dim ChangeAdapterCommand As New SqlCommandBuilder(_MySQLAdapter)
_MySQLtable.DefaultView.Sort = "chrChangeID"
NewRow = _MySQLtable.DefaultView.Find(NewRow)
_MySQLManager.Position = NewRow
MessageBox.Show("Record saved. ", "Save", MessageBoxButtons.OK, MessageBoxIcon.Information)
'Dim ValidateData As New nspMasterBase.ChangeRequest
'Dim EndConnect As New nspMasterBase.MasterBaseConnections
'EndConnect.BreakConnMasterBase()
Dim SetForm As New nspMasterBase.ChangeRequest
Call SetForm.SetState(_MyState)
Catch ex As Exception
MessageBox.Show("Error Saving Record.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try




gwboolean

Continue reading...
 
Back
Top