?
Solved

How to "preserve" the ClientDataSet returned by TSQLConnection.Execute ??

Posted on 2003-03-10
4
Medium Priority
?
765 Views
Last Modified: 2008-02-20
What I want to do:
- spname is the name of any stored procedure that returns rows.
- GetData should initialize mycds with the result of this stored procedure

What I get:
- an empty dataset (mycds) and an access violation when I try to access its
data.




procedure TMyClass.GetData(spname: String; var mycds: TCustomClientDataSet);
begin

    // objSQL is a var declared outside the procedure.
    // SqlConn is a TSQLConnection instance. The connection is established during "Create"

    objSQL := TSQL.Create;
    objSQL.SqlConn.Execute('SELECT * FROM ' + spname', nil, @mycds);
end;

procedure TMyClass.CallGetData;
var
    cds: TCustomClientDataSet;
begin
    GetData('some_Select_sp', cds);
    while not cds.eof do begin
      // something;
      next;
    end;
end;

0
Comment
Question by:hellspawn_9999
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 9

Expert Comment

by:mocarts
ID: 8102846
objSQL.SqlConn.Execute('SELECT * FROM ' + spname', nil, @mycds);

I'm not sure that you can get stored procedure results form SQLConnection's Execute. You must instead use TSQLStoredProc component.
anyway to get results of stored procedure you shouldn't use SELECT * FROM.. but EXEC or simply call your stored procedure

wbr, mo.
0
 

Author Comment

by:hellspawn_9999
ID: 8105195
Hi,

I'm using Interbase at the server side.

If I use EXEC I will be able to retrieve only the first row of the resultset.

I sucessully used the Execute to get my resultset with Kylix 2. The only difference is in that version the "mycds" variable is a local variable (not a parameter), and the return parameter is a String variable that returns the XMLData to the calling procedure/application (see sample below).

I tried to transfer that code to client side in order to improve performance by skipping the Data=>XML conversion, then I got caught in that situation.


(* this code is ok *)

procedure TMyClass.GetData(spname, XMLResult: String);
var
mycds: TCustomClientDataSet;
begin

   objSQL := TSQL.Create;
   objSQL.SqlConn.Execute('SELECT * FROM ' + spname', nil, @mycds);
   XMLResult := mycds.XMLData;
   mycds.Close;
   mycds.Free;
end;

0
 

Expert Comment

by:CleanupPing
ID: 9316859
hellspawn_9999:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 

Accepted Solution

by:
hellspawn_9999 earned 0 total points
ID: 9333408
Problem was the parameter type (TCustomClientDataSet) was not compatible with the variable returned by Execute (TSQLDataSet).

Please refund.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month15 days, 4 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question