DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 5 of 5

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 07: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, 09:44 AM
  2. Replies: 2
    Last Post: 06-27-2003, 12:06 PM
  3. Replies: 0
    Last Post: 02-14-2003, 10: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, 10:39 AM
  5. Replies: 0
    Last Post: 10-11-2002, 10:52 AM

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links