Unable to delete record RRS feed

  • Question

  • MyConnection.Open()
    Dim delStr As String = "DELETE FROM PATIENTS WHERE PatientID='" & tboxPatientID.Text & "'"
    MyCommand = New OleDbCommand(delStr, MyConnection)

    I am using this as my code for my delete button.PatientID was an
    autonumber field in my access database and apparently the application
    was giving me a "Data type mismatch in criteria expression"
    exception.When I replaced the string as
    " DELETE FROM PATIENTS WHERE LastName='" & tboxLastName.Text & "'",
    the code was doing fine, but of course it will delete all records with
    the same lastName.What could be a possible solution here?thanks...

    Thursday, June 22, 2006 5:28 AM


  • Ok I was able to address the issue...

    "DELETE FROM PATIENTS WHERE PatientID=" & Val(tboxPatientID.Text) & ""
    Thursday, June 22, 2006 5:38 AM