
can any one plez tell me how to retrive a row from access to each field of swing... i hav tried this but i am getting an SQL error "SQLExceptionOccurred[Microsoft][ODBC Microsoft Access Driver]COUNT field incorrect".....
if(jTextField1.getText().equals(""))
{
JOptionPane.showMessageDialog(null,"Please enter the Student name to be search","Error",0);
}
else
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:college");
Statement stm=con.createStatement();
ResultSet rs=stm.executeQuery("select * from demo where name=?");
while(rs.next())
{
String address1=rs.getString("address");
String name=rs.getString("name");
jTextArea1.setText(address1);
jTextField1.setText(name);
}
JOptionPane.showMessageDialog(null,"Searched Successfully");
rs.close();
stm.close();
con.close();
}
catch(SQLException sqlex)
{
System.out.println("SQLExceptionOccurred"+sqlex.getMessage());
}
catch(ClassNotFoundException cnfex)
{
System.out.println("ClassNotFoundExceptionOccurred"+cnfex.getMessage());
}
}
plez help me................:-(

import java.awt.*;
import java.sql.*;
import javax.swing.*;
import java.awt.event.*;
class FormDemo{
public static void main(String[]args){
JFrame f=new JFrame();
JPanel panel;
JLabel label1,label2;
final JTextField text1,text2;
label1 = new JLabel();
label1.setText("Name:");
text1 = new JTextField(20);
label2 = new JLabel();
label2.setText("Address:");
text2 = new JTextField(20);
panel=new JPanel(new GridLayout(2,2));
panel.add(label1);
panel.add(text1);
panel.add(label2);
panel.add(text2);
f.add(panel);
try{
String name=JOptionPane.showInputDialog(null,"Please enter the Student name to be search");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:college");
Statement st=conn.createStatement();
ResultSet rs=st.executeQuery("select * from data where name='"+name+"'");
while(rs.next()){
text1.setText(rs.getString("name"));
text2.setText(rs.getString("address"));
}
}
catch(Exception e){}
f.pack();
f.setVisible(true);
}
}
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.