PDA

View Full Version : QSql error



renjithmamman
20th December 2006, 07:26
how can we take the error number . i am using postgresql
i user the methode
int QSqlError::number () const
but it always return -1
y?
pls any body help me

sunil.thaha
20th December 2006, 08:20
Hi,

When you execute a query using QSqlQuery, and it generates an error, Then you can use the QSqlQuery::lastError() to get the QSqlError, Now if the number() returns -1, it just means that there wasn't any error.

joseph
20th December 2006, 08:41
cann't you use ..



int QSqlError::type () const


then check it..

if( type() == QSqlError::None ) //if no error
else if type() == QSqlError::Connection ) // if connection error

----etc

or Try the lastError() as sunil said.

zlatko
20th December 2006, 09:55
For more usability use QSqlError::showMessage()

joseph
20th December 2006, 10:28
mammmuuuu....

Did you get the solution..???

If you got the solution just post it in the forum so that others can use it.