Solved

DCOM-paramatized queries

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi XE10 Round Image 2 123
Performance of SQL statement 37 111
Base1 Encode/Decode 3 77
Slow Restore if incremental backups using RDiff.exe 4 17
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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 tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

785 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