this->connect();
if(this->isConnected){
query.prepare("INSERT INTO clients (`cid`, `firstName`, `lastName`, `address`, `zipCode`, `city`, `phoneNr`, `email`) "
" VALUES( '', :firstName, :lastName, :address, :zipCode, :city, :phoneNr, :email)");
query.bindValue(":firstName", strFirstName);
query.bindValue(":lastName", strLastName);
query.bindValue(":address", strAddress);
query.bindValue(":zipCode", strZipCode);
query.bindValue(":city", strCity);
query.bindValue(":phoneNr", strPhoneNr);
query.bindValue(":email", strEmail);
if(query.exec()){
emit databaseChanged();
return true;
}else{
return false;
}
this->closeConnection();
}
this->connect();
if(this->isConnected){
QSqlQuery query;
query.prepare("INSERT INTO clients (`cid`, `firstName`, `lastName`, `address`, `zipCode`, `city`, `phoneNr`, `email`) "
" VALUES( '', :firstName, :lastName, :address, :zipCode, :city, :phoneNr, :email)");
query.bindValue(":firstName", strFirstName);
query.bindValue(":lastName", strLastName);
query.bindValue(":address", strAddress);
query.bindValue(":zipCode", strZipCode);
query.bindValue(":city", strCity);
query.bindValue(":phoneNr", strPhoneNr);
query.bindValue(":email", strEmail);
if(query.exec()){
emit databaseChanged();
return true;
}else{
QSqlError error = query.lastError();
QString sError = error.text();
QMessageBox::critical(this, tr("SQL error"), sError);
return false;
}
this->closeConnection();
}
To copy to clipboard, switch view to plain text mode
Bookmarks