我有一个登录表单,如果登录成功。我想获取记录的名称,请参见我的代码:
try {
if(jTextField1.getText().equals(""))
{
JOptionPane.showMessageDialog(null, "Pleass Input Username");
}
else if(jPasswordField1.getText().equals(""))
{
JOptionPane.showMessageDialog(null, "Please Input Password");
}
else
{
rs = con.executeQuery("SELECT * FROM MsEmployee WHERE EmployeeID='"+jTextField1.getText()+"' And Password='"+jPasswordField1.getText()+"'");
if (rs.next())
{
help.IDemployee = jTextField1.getText();
JOptionPane.showMessageDialog(null, "Login Success! welcome "+ help.IDemployee);
MainMenu mm = new MainMenu(true);
mm.setVisible(true);
this.dispose();
}else
{
JOptionPane.showMessageDialog(null, "Username not found!!");
}
}
} catch (SQLException ex) {
JOptionPane.showMessageDialog(null,ex.getMessage());
}
所以我想显示它EmployeeName
从中MSEmployee
获得的EmployeeID
。我认为是这样的:
String qry;
qry = "Select EmployeeName From MsEmplyee WHERE EmployeeID = '" + jtextField1.gettext() + "'" ;
但是当我编译时,它只是打印上面的文本,而不是获取值。有人可以帮忙吗?