Results 1 to 3 of 3

Thread: [RESOLVED] [2005] Unable to delete record

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    274

    Resolved [RESOLVED] [2005] Unable to delete record

    VB Code:
    1. MyConnection.Open()
    2.                 Dim delStr As String = "DELETE FROM PATIENTS WHERE PatientID='" & tboxPatientID.Text & "'"
    3.                 MyCommand = New OleDbCommand(delStr, MyConnection)
    4.                 MyCommand.ExecuteNonQuery()
    5.                 MyConnection.Close()

    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...

  2. #2
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    266

    Re: [2005] Unable to delete record

    u need to check datatype of patient_id if its not of string type then u need to convert it like wise
    suppose if its integer then need to some thing like this

    Dim delStr As String = "DELETE FROM PATIENTS WHERE PatientID=" & val(tboxPatientID.Text) & ""

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    274

    Re: [2005] Unable to delete record

    thanks man for your promptness....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width