Solved

DCOM-paramatized queries

Posted on 2000-04-05
5
192 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
  • 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now