Hi, im a student doing a project on attendance system.... i have problem where the text entered (username)from formA jTextField1 need to pass to FormB in order to the combo box in FormB shows(subject,course,time) that correspond to the username was entered in Forma....i have try it....but got error...
Here is the code...it is not full code..
FormA
//value1 as username that entered
String value1=jTextField1.getText();
.....
public String getData()
{
return this.jTextField1.getText();
}
FormB
.....
FormA page = new FormA();
String user = page.getData();
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=C:\\Users\\sumathi\\Documents\\BDdatabase.accdb;}";
Connection con = DriverManager.getConnection(url);
Statement st=con.createStatement();
ResultSet rs=st.executeQuery(" select * from Course where Staff_ID = '" +user+"'");
// JOptionPane.showMessageDialog(null,"stupid","Error",JOptionPane.ERROR_MESSAGE);
//load data from database table Course
while(rs.next()){
jComboBox1.addItem(rs.getString("Subject"));
jComboBox2.addItem(rs.getString("Course"));
jComboBox3.addItem(rs.getString("Time"));
}
}
catch(Exception e){}
}
please me give some solution....tq