Solved

DCOM-paramatized queries

Posted on 2000-04-05
5
198 Views
Last Modified: 2012-05-04
Hi All,

How do I return the result set of a paramatised query in a RemoteDataModule to a DCOM client.

For standard SELECT queries I just attach a TProvider and export it, but if I need to do a SELECT * WHERE FIELD1 = :PARAM1 OR FIELD2 = :PARAM2 what do I need to do?

Code samples will be appreciated.

Thanx,
Gavin

0
Comment
Question by:ShadowFax
[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
  • 2
5 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 2687608
You need to add a new method or some new properties (one for each parameter) to the server module. I would prefer to create a method. Use the type library to add this new method.

When you want to do a new query, the client calls the method with new parameters. In the method, which is running on the server, the actual query has to be done.


Client:

DCOMConnection.Appserver.DoQuery(param1, param2);


Server:

procedure TXXXXX.DoQuery(param1: Integer; const Param2: WideString);
begin
  Query1.Active := false;
  <change query parameters>
  Query1.Active := true;
end;


Regards,

Epsylon.
0
 
LVL 2

Expert Comment

by:kubeerja
ID: 2688365
you can send the whole select string from the client with the parameters like this :

procedure TForm1.SpeedButton1Click(Sender: TObject);
var
  StrSql : OleVariant ;
begin
     StrSql := Memo1.Text ;
      with DM.ClientDataSet2 do
       begin
          Data := Provider.DataRequest(StrSql) ;
       end ;
end;

in the server side do the following :

function TMysrv.Provider2DataRequest(Sender: TObject;
  Input: OleVariant): OleVariant;
begin
     Provider2.DataSet.Close ;
     // Provider1 needs to casted to TQuery type
     // since DataSet in TProvider doesn't support SQL
     TQuery(Provider2.DataSet).SQL.Clear ;
     TQuery(Provider2.DataSet).SQL.Add(Input) ;
     Provider2.DataSet.Open ;
     Result := Provider2.Data ;
end;
0
 

Author Comment

by:ShadowFax
ID: 2689164
Thanx for your responses, after I'd asked the question I worked it out.

Your posts confirmed my attempts.

Both ways work, so who gets the points Epsylon/kubeerja?
0
 
LVL 13

Accepted Solution

by:
Epsylon earned 100 total points
ID: 2690212
The one who is first   :o)
0
 

Author Comment

by:ShadowFax
ID: 2690252
Early worm catches the bird!!!

.....or points in this case, thanx guys for replying.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
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…

691 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