
i am getting a SQL Error while retriving data from access to jframe called "datatype mismatch in criteria expression" plez do help me and studentId's datatye is number......
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(jTextField1.getText().equals(""))
{
JOptionPane.showMessageDialog(null,"Please enter the Student ID to Search","Error",0);
}
else
{
try
{
String ID=jTextField1.getText();
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:college");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from STUDENT where studentid='"+ID+"'");
while(rs.next()){
jTextField1.setText(rs.getString("studentid"));
jTextField2.setText(rs.getString("name"));
jComboBox1.setSelectedItem(rs.getString("course"));
jComboBox2.setSelectedItem(rs.getString("sem"));
jTextField4.setText(rs.getString("father"));
jTextField5.setText(rs.getString("mother"));
jTextField13.setText(rs.getString("dob"));
jTextField6.setText(rs.getString("contactno"));
jTextField7.setText(rs.getString("nationality"));
jTextField8.setText(rs.getString("religion"));
jTextField9.setText(rs.getString("caste"));
jTextArea1.setText(rs.getString("address"));
jTextField10.setText(rs.getString("foccupation"));
jTextField11.setText(rs.getString("moccupation"));
jTextField12.setText(rs.getString("income"));
}
JOptionPane.showMessageDialog(null,"Searched Successfully");
rs.close();
st.close();
con.close();
}
catch(SQLException sqlex)
{
JOptionPane.showMessageDialog(null,"SQLExceptionOccurred"+sqlex.getMessage());
}
catch(ClassNotFoundException cnfex)
{
JOptionPane.showMessageDialog(null,"ClassNotFoundExceptionOccurred"+cnfex.getMessage());
}
}
}
and thanks for all your help.....
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.