Article View: borland.public.cppbuilder.database.ado
Article #2769passing a record set to a routine
From: Mike McCann
Date: Wed, 02 Apr 2003 22:11
Date: Wed, 02 Apr 2003 22:11
56 lines
2518 bytes
2518 bytes
Can someone please tell me what I've done wrong here. I try to pass the
recordset object to the called routine, and in the called routine, I get
pointer fault when I try to access the record set properties or methods
I know it's just my error
Thanks
=======================
Caller:
// Fills a RecordSet with data
// calls a routine to process the recordset
#include "main.h"
#include "ADODB_TLB.h"
TCOM_Connection cn = CoConnection::Create();
cn->ConnectionString = WideString("DSN=localserver").Detach();
cn->CursorLocation = Adodb_tlb::adUseClient;
cn->Open(0,0,0,0);
WideString sql = "SELECT Title FROM response ";
TCOM_Recordset rs = CoRecordset::Create();
rs->Open(sql.Detach(), (IDispatch *)cn, Adodb_tlb::adOpenDynamic,
Adodb_tlb::adLockOptimistic, 0);
TStatsCalculator *myCalculator = new TStatsCalculator();
Edit4->Text = FloatToStr(myCalculator->sMean(rs));
}
=========================================================
Called Routine Header file
===============================================
#include "ADODB_TLB.h"
class TStatsCalculator
{
private:
public:
TStatsCalculator(void);
~TStatsCalculator(void);
double TStatsCalculator::sMean(TCOM_Recordset& rs);
};
=========================================================
Called Routine main file
===============================================
double TStatsCalculator::sMean(TCOM_Recordset& rs)
{
double localMean = 0.0;
double numberRecords = rs->RecordCount;
}
Technical Details
Message-ID:
<3e8b601c@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,aa52e8a79c5f769,start X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2003-04-02 14:18:24 PST Reply-To: "Mike McCann" <mmc@systemsthinking.com.au> From: "Mike McCann" <mmc@systemsthinking.com.au> Newsgroups: borland.public.cppbuilder.database.ado Subject: passing a record set to a routine Date: Thu, 3 Apr 2003 08:11:55 +1000 Lines: 58 Organization: Systems Thinking Pty Ltd X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 144.132.128.16 Message-ID: <3e8b601c@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1049321500 144.132.128.16 (2 Apr 2003 14:11:40 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail