Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check the return value of a function

Status
Not open for further replies.

MindCracker

Programmer
Aug 27, 2002
21
0
0
GB
Hi,

just a very simply question. I got a function.

Bool CDialogTest::OpenFiles()
{
ODBCCall::GetTables(db, tables);
... }

N/B: db is defined as CDatabase and tables are strings. My answer is very simple, how to check the return value of ODBCCall from the BOOL CDialogTest. Please help. Many thanks



 
Bool CDialogTest::OpenFiles()
{
return ODBCCall::GetTables(db, tables);
}

...
if(OpenFIles())
{
// good
}
else
{
// bad
}


or

Bool CDialogTest::OpenFiles()
{
if(ODBCCall::GetTables(db, tables))
{
// do stuff
return true;
}
else
{
return false;
}
}

Matt
 
Hi Matt,

Thank you for help. I have one more question. In my CDialog Class. I have a database defined as CDatabase locally: -

CDatabase db; (declared in CDialog Class header file)

BOOL CDialogODBC::Opendatabase() //in CDialog source files.
db.Open(NULL,false,false,"ODBC;",TRUE);
.....

I have another file defined as ODBCImporter Class. This class need the information from db in a dialog file. My question is how to pass the information so that the ODBCImporterClass can recognise that db has been opened and trying to get the value from there.

In my ODBCImporter Class Header file, I define:
Protected:
//-Paramters.............
CDatabase *database;

//- Database Parameters.............
bool SetDatabase(CDatabase *database) {database_=database; return true;}
CDatabase *GetDatabase() const {return database_;}

In my ODBCImporter source file, when I wrote this:
if (GetDatabase() == NULL {
Message::Error("Error.");
return false; }

And I always got this error message indicating that database is faulty. Can you please help me on this??? Many thanks..









 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top