[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.

Hybrid View

  1. #1
    Join Date
    Jun 2008
    Posts
    4

    [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.

    Alright, I'm having some really funky issue with this. I know it's a mismatch (obviously) and I want to know if the DevX community members can help me solve this issue. It's been annoying me a lot of late.

    Code:
      try{
            libSQL myAddNewData = new libSQL();
            String strRownum =(String.valueOf(jComboBoxLName.getSelectedItem()));
            if (intChoice == 1){
                myAddNewData.AddNewData("INSERT INTO CUSDATA (FIRSTNAME, LASTNAME, PHONE, SIN) VALUES ('"+ strUserData[intCount][0] +"','" + strUserData[intCount][1] + "','"  + strUserData[intCount][5] + "','" + strUserData[intCount][8] + "')");
                myAddNewData.AddNewData("INSERT INTO CUSLOCATION (ADDRESS, CITY, [POSTAL CODE], COUNTRY, PROVINCE) VALUES ('" + strUserData[intCount][2] + "','" + strUserData[intCount][3] + "','" + strUserData[intCount][4] + "','" +strUserData[intCount][6] + "','" + strUserData[intCount][7] + "')");   
            }
            if (intChoice == 2){
                myAddNewData.AddNewData("UPDATE CUSDATA SET FIRSTNAME = '" + jTextFieldFName.getText() + "', PHONE = '" + jTextFieldPh.getText() + "', SIN = '" + jTextFieldSIN.getText() + "' WHERE ID = '" + strRownum + "'");
                myAddNewData.AddNewData("UPDATE CUSLOCATION SET ADDRESS='" +  jTextFieldAddr.getText() + "', CITY = '" + jTextFieldCity.getText() +"', [POSTAL CODE] = '" + jTextFieldPC.getText() + "'  WHERE ID = '" + strRownum + "'");
            }
            if (intChoice == 3){
                myAddNewData.AddNewData("DELETE FROM CUSDATA WHERE ID = '" + strRownum + "'");
                myAddNewData.AddNewData("DELETE CUSLOCATION WHERE ID = '" + strRownum + "'");
            }
        }catch(Exception e){
            jTextArea1.append("SQLException: " + e.getMessage());
        }
    The error I get when I initiate the UPDATE command:
    init:
    deps-jar:
    Compiling 1 source file to D:\devel\java\netbeans\Grade 12\SIN\build\classes
    compile:
    run:
    Error: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
    Error: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
    BUILD SUCCESSFUL (total time: 36 seconds)
    Here's a screenshot of my databases:



    Thanks,
    deltatux

  2. #2
    Join Date
    Jun 2008
    Posts
    5
    "String strRownum ="
    DB: ID = LongInt

    Tried converting strRownum to Int before using for DB access?

  3. #3
    Join Date
    May 2008
    Location
    Chicago, IL
    Posts
    64
    The query would be right for all string fields, but for any numeric type, leave off the ', so change this:
    Code:
      "('"+ strUserData[intCount][0] +"'
    to this:

    Code:
      "("+ strUserData[intCount][0] +"
    for Date fields:

    Code:
      "(#"+ strUserData[intCount][0] +"#,"...
    Last edited by dglienna; 06-10-2008 at 08:57 PM.
    David CodeGuru Article: Bound Controls are Evil-VB6

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  4. #4
    Join Date
    Jun 2008
    Posts
    4
    Quote Originally Posted by dglienna
    The query would be right for all string fields, but for any numeric type, leave off the ', so change this:
    Code:
      "('"+ strUserData[intCount][0] +"'
    to this:

    Code:
      "("+ strUserData[intCount][0] +"
    for Date fields:

    Code:
      "(#"+ strUserData[intCount][0] +"#,"...
    Thanks, I'll try that and see.

  5. #5
    Join Date
    Jun 2008
    Posts
    4
    Quote Originally Posted by LitlGreyCells
    "String strRownum ="
    DB: ID = LongInt

    Tried converting strRownum to Int before using for DB access?
    My original code had that, it didn't work and then I tried my friend's code who's code is in string.

Similar Threads

  1. Data type mismatch using date() function
    By rdwagco2 in forum Database
    Replies: 5
    Last Post: 08-03-2005, 10:44 AM
  2. Replies: 2
    Last Post: 06-27-2003, 01:06 PM
  3. Replies: 0
    Last Post: 02-14-2003, 11:41 AM
  4. undertakes any type of data entry (microsoft based software)
    By chiradip das chiradip_rediffmail.com in forum Careers
    Replies: 0
    Last Post: 02-14-2003, 11:39 AM
  5. Replies: 0
    Last Post: 10-11-2002, 11:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center