將nvarchar值'XX'轉換爲數據類型int時轉換失敗。即時通訊有這些錯誤,我不知道如何處理它。請幫幫我。謝謝。 :d將nvarchar值「XX」轉換爲數據類型int時轉換失敗。 in java eclipse
btnNewButton_3.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
String value1=textField_7.getText();
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connectionURL = "jdbc:sqlserver://;Database='';user='';password='';";
Connection con = DriverManager.getConnection(connectionURL);
PreparedStatement pst =null;
//Statement stmt=con.createStatement();
//PreparedStatement pst=con.prepareStatement("select * from inventory where Id=? or Name=? ");
String sql ="select * from inventory where Id=? or Name=? ";
pst=con.prepareStatement(sql);
pst.setString(1, textField_7.getText());
pst.setString(2, textField_7.getText());
ResultSet rs = pst.executeQuery();
if(value1.equals("")){
reloadData();
model.fireTableDataChanged();
JOptionPane.showMessageDialog(null,"Please Enter a Name or Id of the Item","ERROR",JOptionPane.ERROR_MESSAGE);
}else{
table.setModel(DbUtils.resultSetToTableModel(rs));
}
}
catch(Exception e1){e1.printStackTrace();}
}
});