Public Shared Sub UpdateData(ByVal aCustomer As Customer)
Dim name As String
Dim address As String
Dim phoneNo As String
Dim Key As String
Name = aCustomer.GetName()
Address = aCustomer.GetAddress()
PhoneNo = aCustomer.GetPhoneNo()
Key = phoneNo
conHanDler.Open()
Dim sqlUpdate As String = " Update Customer " & " Set Name = '" & name & "', Address = '" & address & "'," & " Where PhoneNo = '" & Key & "'"
'Dim sqlUpdate As String = "Update Customer" & "Set Name = " & name & " & " WHERE PhoneNo = '" & Key & "'"
Dim New_DataAdapter As New OleDbDataAdapter()
'Check if customer exists
Dim Dscustomer As New DataSet
'Define the Sql Statement using the phone key
Dim sqlQue As String = " Select Name, Address,PhoneNo " & "from Customer where PhoneNo = '" & Key & "'"
Dim adapCustomer As New OleDbDataAdapter(sqlQue, conHanDler)
adapCustomer.Fill(Dscustomer, "Customer")
If Dscustomer.Tables("Customer").Rows.Count > 0 Then
Dim CustRow As DataRow
CustRow = Dscustomer.Tables("Customer").Rows(0)
Name = CustRow.Item("Name")
Address = CustRow.Item("Address")
PhoneNo = CustRow.Item("PhoneNo")
aCustomer = New Customer(Name, Address, PhoneNo)
MessageBox.Show("Customer exists")
'Else
'Dscustomer = Nothing
'Assign insert command and execute
New_DataAdapter.UpdateCommand = New OleDbCommand(sqlUpdate)
New_DataAdapter.UpdateCommand.Connection = conHanDler
New_DataAdapter.UpdateCommand.ExecuteNonQuery()
MessageBox.Show(" i am here 4")
'ListRecord()
End If
End Sub