我得到「列計數與第1行的值計數不匹配」,但似乎無法修復它。我試着改變引號和數據類型,但仍然沒有運氣。任何人都可以看到我出錯的地方嗎?第1行的列計數與值計數不匹配 - Java SQL
public void actionPerformed(ActionEvent arg0) {
if(!textField.getText().isEmpty() && !textField_1.getText().isEmpty() && !textField_2.getText().isEmpty() && !textField_3.getText().isEmpty() && !textField_4.getText().isEmpty() && !textField_5.getText().isEmpty() && !textField_6.getText().isEmpty() && !textField_7.getText().isEmpty())
{
String moduleName = textField.getText();
String studId = textField_1.getText();
String sFName = textField_2.getText();
String sLName = textField_3.getText();
int weekNo = Integer.parseInt(textField_4.getText());
int lAttend = Integer.parseInt(textField_5.getText());
int tAttend = Integer.parseInt(textField_6.getText());
int wAttend = Integer.parseInt(textField_7.getText());
lh.addStud(moduleName, studId, sFName, sLName , weekNo, lAttend, tAttend, wAttend);
}
else
{
lblNewLabel_4.setText("You have Missing Field");
}
fillDB();
}
});
下面是我的查詢:
String aSQuery = "INSERT INTO Group6_Register VALUES ('" + moduleName + "', '" + studId + "', '" + sFName + "', '" + sLName +"', '" + weekNo + "', '" + lAttend + "', '" + tAttend + "', '" + wAttend + "')";
statements = connection.prepareStatement(aSQuery);
statements.executeUpdate();
我想設置一個值'這裏省略Group6_Register'的'PK'領域 – triclosan
在哪裏'prepareStatement'在這裏? – triclosan