Page 1 of 1

wxSQLite3ResultSet - Cannot return NULL?

Posted: Fri Sep 17, 2010 5:33 pm
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?

Re: wxSQLite3ResultSet - Cannot return NULL?

Posted: Fri Sep 17, 2010 8:07 pm
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

Posted: Sat Sep 18, 2010 1:21 pm
by evstevemd
that is cool and simple method. Thanks Urlich.