🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #5019

Re: Retrieving Results

#5019
From: Michael Crapo
Date: Wed, 22 Aug 2001 13:19
109 lines
3629 bytes
John.

	I don't know what you problem may be.  I can not see any code
where you are initalizing the ADODataSet.  Here is a function that I
use all the time.  Hope it helps..

bool __fastcall TMyDatabase::AddExecuteCmdEx(TADOCommand *Cmd,
TADODataSet *DS)
{
    try
        {
        if(ConnectDB())
            {
            Cmd->Connection  = ADOConnection;
            DS->CursorType = ctStatic;
            DS->CacheSize = 100000;
            DS->CursorLocation = clUseServer;
            DS->LockType = ltReadOnly;
            DS->CommandTimeout = 420;
            Cmd->CommandTimeout = 420;
            DS->Recordset = Cmd->Execute();
            }
        return(true);
        }
    catch(Exception &e)
        {
        LastError = e.Message;
        return(false);
        }
     catch(...)
        {
        LastError = "";
        return(false);
        }
}


ConnectDB is just a function to connect to the database.
ADOConnection is a variable in the Class. Here is how I call the
function..

bool __fastcall TFileHandler::GetRecord()
{
    TADOCommand *objCmd = new TADOCommand(0);
    TADODataSet *objDataSet = new TADODataSet(0);
    try
        {
	String Info;
        String Query = "SELECT * from Table";
        
	objCmd->CommandText = WideString(Query);
        try
            {
            if(MyDatabase->AddExecuteCmdEx(objCmd, objDataSet))
                {
                Info = objDataSet->Fields->Fields[0]->AsString;
                }
            }
        catch(...)
            {
            //Error Log
            }
        delete objCmd;
        delete objDataSet;
        return(true);
        }
    catch(...)
        {
        MyDatabase->DisConnectDB();
        delete objCmd;
        delete objDataSet;
        return(false);
        }
}

Hope that helps..  Let me know if you get it to work...

Mike


On Tue, 21 Aug 2001 20:16:26 GMT, mcdonald@airtalk.com (John McDonald)
wrote:

>Michael,
>
>I've tried this already..My original post was incorrect with
>the following line:      ADOCommand1->Execute();
>Using the code below still produces a stack overflow
>when ADODataSet2->Recordset = ADOCommand1->Execute();
>is executed:
>
> ADOCommand1->Connection = ADOConnection1;
>ADOCommand1->Parameters->Clear();
>ADOCommand1->CommandText = WideString(Text);
>//Text = "util.set_psm_ack(3456,321,'Testing..')";
>ADOCommand1->CommandType = cmdStoredProc;
>ADOCommand1->ParamCheck = false;
>ADODataSet2->Recordset = ADOCommand1->Execute();
>
>Are there special preparations for ADODataSet2 before
>in can be used with ADOCommand??  Documentation for
>ADO is a big pile of CRAP complete with incorrect
>examples that won't even compile.   
>
>John
>
>
>
>
Technical Details
Message-ID: <3b83b03c.1143113@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews
References: <3b8131d6.570235@newsgroups.borland.com> <3b825ae6.627592@newsgroups.borland.com> <3b82bef8.23158265@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10698b,79925ae67771c000
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2001-08-22 06:37:03 PST
From: mcrapo@tng-ida.com (Michael Crapo)
Newsgroups: borland.public.cppbuilder.database.ado
Subject: Re: Retrieving Results
Date: Wed, 22 Aug 2001 13:19:58 GMT
Message-ID: <3b83b03c.1143113@newsgroups.borland.com>
References: <3b8131d6.570235@newsgroups.borland.com> <3b825ae6.627592@newsgroups.borland.com> <3b82bef8.23158265@newsgroups.borland.com>
X-Newsreader: Forte Free Agent 1.21/32.243
NNTP-Posting-Host: 207.170.242.1
X-Trace: dnews 998486487 207.170.242.1 (22 Aug 2001 06:21:27 -0700)
Lines: 110
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews