Solved

DCOM-paramatized queries

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

808 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