wxSQLite3ResultSet - Cannot return NULL? Topic is solved

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

wxSQLite3ResultSet - Cannot return NULL?

Post by evstevemd »

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?
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxSQLite3ResultSet - Cannot return NULL?

Post by utelle »

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: 2408
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Post by evstevemd »

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?
Post Reply