?
Solved

DCOM-paramatized queries

Posted on 2000-04-05
5
Medium Priority
?
199 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 300 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month13 days, 21 hours left to enroll

800 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