🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Assign to TADORecordSet

#1333
From: Viatcheslav V. Vassiliev
Date: Sat, 28 Aug 2004 06:00
68 lines
3004 bytes
Try do:

rs = Command->Execute();
while (!rs->State = adStateOpen) rs = rs->NextRecordset(recAffected);
if (rs->State = adStateOpen) DataSet->Recordset = rs;
else ... //Recordset is not returned.

rs is ADO recordset, from ADOInt.hpp.

Recordset could be closed if your sp has some SQL commands that do not
return data as first instructions.

//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)

"Paul Cheetham" <PAC.News@dsl.pipex.com> �������/�������� � ��������
���������: news:MPG.1b99a114ae2276db98968f@Newsgroups.Borland.com...
>
> Hi,
>
> I have an application where I am trying to read data from an MS SQL
> table using stored procedures.
> I have created the stored procedure, and it works fine.
> If I use the code below, I get an error.
>
>
>
>   Command = new TADOCommand (NULL);
>   DataSet = new TADODataSet (NULL);
>   Command->Connection = _Connection;
>   Command->CommandType = cmdStoredProc;
>   Command->CommandText = "pr_tblCustomers_SelectOne_ByCustNo";
>   Command->Parameters->Clear();
>
>   Command->Parameters->CreateParameter ("@iiCustNo", ftInteger, pdInput,
> 4, _iCustomerNumber);
>   Command->Parameters->CreateParameter ("@iiErrorCode", ftInteger,
> pdOutput, 4, 0);
>
>   // Execute command and return recordset.
>   DataSet->Recordset = Command->Execute();
>
>
> The line above generates the error  "Record set is not open"
> If I use the line:
>   Command->Execute();
>  it works fine, so the problem must be with assigning the returned
> recordset to the DataSet object.
>
>
> Can anybody tell me where I am going wrong?
>
> Thankyou.
>
>
>
>
>
> -- 
> Paul Cheetham
>
> "There are 10 types of people in the world - those that understand
> Binary, and those that don't."
Technical Details
Message-ID: <41301f8a$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshosting.com!nx01.iad01.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <MPG.1b99a114ae2276db98968f@Newsgroups.Borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,592a3d7e1719af81
X-Google-Attributes: gid10698b,public
X-Google-Language: ENGLISH,ASCII
From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com>
Newsgroups: borland.public.cppbuilder.database.ado
References: <MPG.1b99a114ae2276db98968f@Newsgroups.Borland.com>
Subject: Re: Assign to TADORecordSet
Date: Sat, 28 Aug 2004 10:00:30 +0400
Lines: 70
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
NNTP-Posting-Host: 213.234.218.42
Message-ID: <41301f8a$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1093672842 213.234.218.42 (27 Aug 2004 23:00:42 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshosting.com!nx01.iad01.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail