else
{
query->prepare ("insert into Courses values (?,?,?)");
query->bindValue (0,courseIDLine->text ());
query->bindValue (1,courseNameLine->text ());
query->bindValue (2,courseTeacherIDLine->text ());
successful=query->exec ();
}
if(successful)
{
closeInsertCourseDlg ();
}
else if(!errorMsg->isVisible ())
{
//cannot execute the statement
}
else
{
query->prepare ("insert into Courses values (?,?,?)");
query->bindValue (0,courseIDLine->text ());
query->bindValue (1,courseNameLine->text ());
query->bindValue (2,courseTeacherIDLine->text ());
successful=query->exec ();
}
if(successful)
{
closeInsertCourseDlg ();
}
else if(!errorMsg->isVisible ())
{
//cannot execute the statement
}
To copy to clipboard, switch view to plain text mode
but if the SQL statement doesn't satisfy the foreign key, the program will end unexpectedly, it will not just return a false
how to change the code??
Bookmarks