PDA

View Full Version : SQL exception handling



Attila Kovács
27th January 2017, 07:28
Hello

I use QqSqlTableModel and tableView together.
How can i detect SQL server exceptions, errors ? (for example : Key violation, foreign key error etc....)

thnak you Attila

anda_skoa
27th January 2017, 09:47
See QSqlTableModel::lastError() on how to get an SQL error object.

Cheers,
_

Attila Kovács
27th January 2017, 09:56
Thank you anda_skoa

but i edit the recod in a tableview manually
How can i get a message about the record is saved or not (because of sql error)

thank you Attila

anda_skoa
27th January 2017, 12:22
If you run through the model, then it has the error. That's why it is called "lastError".

If you run a QSqlQuery manually, then it has its own error object.

Cheers,
_

Attila Kovács
27th January 2017, 14:30
Thank you , Sir

Ok. It's working. I have understood.

thank you again