Normal
Moin,habe eine Frage wie ich das Choicefeld mit einer SQL-Anfrage verbinde. So dass wenn ich 1 in Choicefeld wähle, das der Name von einer Person mit einer ID angezeigt wird z.B. 1 = Max Mustermann.Habe mal ein Javacode-Ausschnitt eingefügt. Und ein Bild zum Verständnis, wie es Aussehen soll.[code=Java]int countPersonID;Choice chPersonID; public void chPersonID() { Statement stmt = null; ResultSet rs = null; try { stmt = (Statement) pConnect.getConnection().createStatement(); rs = stmt.executeQuery("SELECT count(ID_Person) FROM tbl_Person"); rs.next(); countPersonID = rs.getInt(1); } catch (SQLException e) {} catch (NullPointerException e) {} chPersonID.add("Not Selected"); for (int i=1;i<countPersonID + 1;i++) { chPersonID.add(Integer.toString(i)); } }[/code]mfg Brückenchiller
Moin,
habe eine Frage wie ich das Choicefeld mit einer SQL-Anfrage verbinde. So dass wenn ich 1 in Choicefeld wähle, das der Name von einer Person mit einer ID angezeigt wird z.B. 1 = Max Mustermann.
Habe mal ein Javacode-Ausschnitt eingefügt. Und ein Bild zum Verständnis, wie es Aussehen soll.
[code=Java]
int countPersonID;
Choice chPersonID;
public void chPersonID()
{
Statement stmt = null;
ResultSet rs = null;
try
stmt = (Statement) pConnect.getConnection().createStatement();
rs = stmt.executeQuery("SELECT count(ID_Person) FROM tbl_Person");
rs.next();
countPersonID = rs.getInt(1);
}
catch (SQLException e)
{}
catch (NullPointerException e)
chPersonID.add("Not Selected");
for (int i=1;i<countPersonID + 1;i++)
chPersonID.add(Integer.toString(i));
[/code]
mfg Brückenchiller