当我运行代码at mylogin.Basket.makesales(Basket.java:160)
at mylogin.Basket.ReceiptActionPerformed(Basket.java:455)
at mylogin.Basket.access$100(Basket.java:23)
时,我在String qquery中收到错误我的sql qquery在sqlserver中正常运行他减去了产品数量。任何想法? ty
错误日志
public void executeSQLQuery (String query,String message) {
Connection con =getConnection();
Statement st;
try{
st =con.createStatement();
if((st.executeUpdate(query))==1)
{
con.commit();
DefaultTableModel model=(DefaultTableModel)jTable_ProSales.getModel();
model.setRowCount(0);
show_Basket_in_Jtable();
JOptionPane.showMessageDialog(null,"Data "+message+" Succefully");
}else{
JOptionPane.showMessageDialog(null,"Data Not "+message+ "Error");
}
}catch (Exception ex){
ex.printStackTrace();
}
}
这是我的代码
private void ReceiptActionPerformed(java.awt.event.ActionEvent evt) {
String query= "INSERT INTO Sales (Pro_Id ,Pro_Name,Sales_Quantity,Pro_Price ) SELECT Pro_Id,Pro_Name,Sales_Quantity ,Pro_Price FROM Receipt";
executeSQLQuery(query,"Inserted");
String qquery= " UPDATE Products SET Pro_Quantity= Products.Pro_Quantity - Receipt.Sales_Quantity FROM Products INNER JOIN Receipt ON Products.Pro_Id = Receipt.Pro_Id)" ;
executeSQLQuery(qquery,"updated");
}
操作按钮
event.value = util.printf("%,106d", event.value) ;
答案 0 :(得分:-1)
private void ReceiptActionPerformed(java.awt.event.ActionEvent evt) {
String query= "INSERT INTO Sales (Pro_Id ,Pro_Name,Sales_Quantity,Pro_Price ) SELECT Pro_Id,Pro_Name,Sales_Quantity ,Pro_Price FROM Receipt";
executeSQLQuery(query,"Inserted");
String qquery= " UPDATE Products SET Pro_Quantity= Products.Pro_Quantity - Receipt.Sales_Quantity FROM Products INNER JOIN Receipt ON Products.Pro_Id = Receipt.Pro_Id" ;
executeSQLQuery(qquery,"updated");
}