wxSQLite3ResultSet - Cannot return NULL?  [SOLVED]

In this forum you can discuss database related issues which can be wxWidgets related, but also generic in nature.
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2092
Joined: Wed Jan 28, 2009 11:57 am
Location: Dar es Salaam, United Republic of Tanzania
Contact:

wxSQLite3ResultSet - Cannot return NULL?

Postby evstevemd » Fri Sep 17, 2010 5:33 pm

I have a function that returns wxSQLite3ResultSet . However I want it to return NULL if something goes wrong. I cannot as it throws error:
error: conversion from 'int' to non-scalar type 'wxSQLite3ResultSet' requested

Is there alternative trick?
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

utelle
Moderator
Moderator
Posts: 824
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxSQLite3ResultSet - Cannot return NULL?  [SOLVED]

Postby utelle » Fri Sep 17, 2010 8:07 pm

evstevemd wrote:I have a function that returns wxSQLite3ResultSet . However I want it to return NULL if something goes wrong. I cannot as it throws error:
error: conversion from 'int' to non-scalar type 'wxSQLite3ResultSet' requested

Is there alternative trick?

Just return an invalid result set and check it in the calling procedure:

Code: Select all

wxSQLite3ResultSet myFunction()
{
  //...
  if (error)
    return wxSQLite3ResultSet();
}

// code calling the function
wxSQLite3ResultSet myResultSet = myFunction();
if (myResultSet.IsOk())
{
  // process result set
}
else
{
  // handle error condition
}


Regards,

Ulrich

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2092
Joined: Wed Jan 28, 2009 11:57 am
Location: Dar es Salaam, United Republic of Tanzania
Contact:

Postby evstevemd » Sat Sep 18, 2010 1:21 pm

that is cool and simple method. Thanks Urlich.
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]


Return to “Database Related”

Who is online

Users browsing this forum: No registered users and 1 guest