-
July 12th, 2013, 04:26 AM
#1
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);
}
}
}
}
-
July 13th, 2013, 05:39 PM
#2
Re: Data type mismatch in criteria expression.
Originally Posted by 2012-arika
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"
-
July 14th, 2013, 11:54 PM
#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....
-
July 15th, 2013, 01:50 AM
#4
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.
-
July 15th, 2013, 05:00 AM
#5
Re: Data type mismatch in criteria expression.
Originally Posted by DataMiser
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|