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);
}
}
}
}
Re: Data type mismatch in criteria expression.
Quote:
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"
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....
Re: Data type mismatch in criteria expression.
What is the data type in the database for the field in question?
Re: Data type mismatch in criteria expression.
Quote:
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..