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

wxSQLite3ResultSet - Cannot return NULL?

Post by 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: 844
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxSQLite3ResultSet - Cannot return NULL?

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

Post by 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]

Post Reply