My code: Update sub
Sub UpdateCustomer(ByVal HNCNO As Integer, ByVal Forename As String, ByVal Surname As String, ByVal DOB As String, ByVal actionedBY As String)
OpenDatabaseConnction()
Dim cm As New OleDb.OleDbCommand(" Update Details Set HNCNO = '" & HNCNO & "',Forename= '" & Forename & "',Surname= '" & Surname & "',DOB='" & DOB & "',ationedBY='" & actionedBY & "' WHERE HNCNO = " & HNCNO, DBCon)
MessageBox.Show(cm.CommandText.ToString())
Try
cm.ExecuteScalar()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
CloseDatabaseConnction()
End Try
End Sub
the save button
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Dim customerDS As DataSet
Dim ans As Integer
customerDS = dataAccess.ShowSpecficCustomer(frmShowAllDetails.HNCNO)
If txtDOB.Text <> customerDS.Tables("Details").Rows(0).Item(3).ToString() Then
ans = MessageBox.Show("DOB is not the same. Do you still want to save", "", MessageBoxButtons.YesNo)
If ans = Windows.Forms.DialogResult.No Then
Exit Sub ' if the user clicks the no option on the message box then exit this sub and don't save
End If
End If
dataAccess.UpdateCustomer(frmShowAllDetails.HNCNO, txtForename.Text, txtSurname.Text, txtDOB.Text, txtActionedBy.Text)
MsgBox("Customer updates saved", MsgBoxStyle.Information)
Dim ds As DataSet
ds = dataAccess.ShowALLCustomerAccountDetails()
Me.Close()
frmShowAllDetails.Show()
End Sub

New Topic/Question
Reply




MultiQuote



|