I am getting the "Column count doesn't match value count at row 1" but I couldn't seem to fix it. I tried changing the quotation marks and data type but still no luck. Can anyone see where I've gone wrong?
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();
}
});
Below is my query:
String aSQuery = "INSERT INTO Group6_Register VALUES ('" + moduleName + "', '" + studId + "', '" + sFName + "', '" + sLName +"', '" + weekNo + "', '" + lAttend + "', '" + tAttend + "', '" + wAttend + "')";
statements = connection.prepareStatement(aSQuery);
statements.executeUpdate();