Data type mismatch in criteria expression.
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Data type mismatch in criteria expression.

  1. #1
    Join Date
    Jul 2013
    Posts
    3

    Unhappy Data type mismatch in criteria expression.

    hi,

    any one pls help me...i am getting the sql exception when running my code.
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.

    here is my code :

    class submit extends Frame implements ActionListener
    {
    int num,no=0;
    String name,addr,blgr,hist,pid,dob,current,room,dateadd,rtype,mf,docname;



    public void actionPerformed(ActionEvent ae)
    {


    try{

    num=Integer.parseInt(tftel.getText());

    Statement st=cn.createStatement();
    ResultSet rs=st.executeQuery("SELECT * FROM PAT WHERE contact="+num);
    System.out.println(num);

    if(rs.next())
    {
    no=rs.getInt("contact");
    pid=rs.getString("patientno");
    name=rs.getString("name");
    addr=rs.getString("address");
    hist=rs.getString("history");
    dob=rs.getString("dob");
    current=rs.getString("current");
    blgr=rs.getString("bloodgroup");
    room=rs.getString("roomno");
    dateadd=rs.getString("dateadd");
    rtype=rs.getString("rtype");
    mf=rs.getString("gender");
    docname=rs.getString("docname");


    tfpno.setText(pid);
    tfname.setText(name);
    tfdob.setText(dob);
    taadd.setText(addr);
    tahis.setText(hist);
    tacur.setText(current);
    tfbg.setText(blgr);
    tfroom.setText(room);
    tfdateadd.setText(dateadd);
    tfrtype.setText(rtype);
    tfmf.setText(mf);
    tfdocname.setText(docname);
    }



    }
    catch(SQLException sq)
    {
    System.out.println(sq);
    }


    }
    }

    }

  2. #2
    Join Date
    May 2005
    Location
    San Antonio Tx
    Posts
    44

    Re: Data type mismatch in criteria expression.

    Quote Originally Posted by 2012-arika View Post
    hi,
    any one pls help me...i am getting the sql exception when running my code.
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
    check to see which line of the code causes the sql exception, all of your variables are of type string so it is possible that there might be a type mismatch in one of your assignments for exemple your dob=rs.getString("dob"); might be returning an object of type "datetime" instead of "string"

  3. #3
    Join Date
    Jul 2013
    Posts
    3

    Re: Data type mismatch in criteria expression.

    in my code i am trying to get "contact" as integer..."no=rs.getInt("contact");
    am i making any mistake in printing Contact as integer. does this is causing mismatch.pls suggest in what way i can use if i want to get contact as integer....

  4. #4
    DataMiser is online now Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,786

    Re: Data type mismatch in criteria expression.

    What is the data type in the database for the field in question?
    Always use [code][/code] tags when posting code.

  5. #5
    Join Date
    Jul 2013
    Posts
    3

    Re: Data type mismatch in criteria expression.

    Quote Originally Posted by DataMiser View Post
    What is the data type in the database for the field in question?
    Data type of contact in D/B is: Number
    feild size is: Long Integer..

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center