السلام عليكم ... لوسمحتوا عندي فريم1 فيه خيارات لاسماء اماكن ولكل اسم ID فالداتابيس بحيث لما اختار اسم مكان تطلع المعلومه للمكان ففريم2 في jlabel وفريم2 فيه زر update للمعلومه...
الكود اللي جربته يصلح لمعلومه وحده للفريم2 وكنت احدد فيه ID معين لاسم مكان واحد
فاريد شو اغير فالكود عشان استدعي معلومه كل مكان بنفس الفريم 2 ؟؟؟
هذا كود لربط الفريم بالداتابيس
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cn=DriverManager.getConnection("jdbc:odbc:system");
PreparedStatement st=cn.prepareStatement("select * from information where ID=23");
re=st.executeQuery();
re.next();
jLabel1.setText(re.getString(2));
jLabel2.setText(re.getString(3));
str+=re.getString(2);
str1+=re.getString(3);
}
catch(Exception exp)
{System.out.print(exp);}وهذا كود زر update
try{
if(jTextArea2.getText().length()==0)
{
JOptionPane.showMessageDialog(null,"Please insert the name of place");
}
else if(jTextArea1.getText().length()==0)
{
JOptionPane.showMessageDialog(null,"Please insert your description");
}
else
{
String q="update information SET Place=?,Decription=? where ID=1" ;
PreparedStatement ps=cn.prepareStatement(q);
ps.setString(1,jTextArea2.getText());
ps.setString(2,jTextArea1.getText());
int t =ps.executeUpdate();
JOptionPane.showMessageDialog(null,"Your data updated","THANK YOU",1);
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,e.getMessage());
}ما اعرف اذا تصير بطريقة استدعاء method فريم1 في فريم2 ؟؟؟؟؟ اللي يعرف يرسلي كود لكيفية استدعاء method
ارجو الافادة ...تحياتي