Delphi XE では、「DataSnap サーバー」ウィザードを使用してクライアント サーバー アプリケーションを作成します。
この「Select * from TABLE」のようなSQLプロパティServerMethodUnit
を定義するTSQLQuery
私も呼び出される関数を定義します。ChangeSQL
例によってServerMethodUnit
sql プロパティを変更するものSELECT * from TABLE where ID = 5
ChangeSQL
を介してフォームクライアントアプリケーションを呼び出すTSQLServerMethod
と、関数のプロパティがChangeSQL
変更されますが、関数を離れると、新しいSQLコマンドは含まれていませんが、元のSQLがあります。SQL
ServerMethodUnit
ChangeSQL
TSQLQuery
EDIT:コードサンプルの追加
「DataSnap サーバー」ウィザードを使用して、新しいクライアント サーバー アプリケーションを作成します。
でServerMethodsUnit
:
TSQLConnection
私は自分のデータベースに入れました。I put a TSQLQuery
call MyQuery
, with SQL
property = 'Select * from client' I put a TDataSetProvider
toTSQLQuery
そして、次のような関数を定義します。
function TServerMethods1.ClientFiltrer (ID:integer):integer;
begin
// ------------------------------------------------ // この時点で、MyQuery.RecordCount = すべてのレコード (初回と次の両方) // --------------------------- ----------------------
if MyQuery.Active then
MyQuery.close;
MyQuery.SQL.Clear;
MyQuery.SQL.Add(' SELECT * from CLIENT where ID = '+StrToInt (ID));
MyQuery.Open;
result := MyQuery.RecordCount;
// ------------------------------------------------
// At this point, MyQuery.RecordCount = ONE record
// ------------------------------------------------
end;
そして、「DataSnap クライアント」で新しいアプリケーションを作成します
にClientModuleUni
: を配置しClientDataSet
、MyClientDS
withRemoteServer
とProviderName
自分のMyQuery
プロバイダーに呼び出します。を指すTSQLServerMethod
呼び出しを入れましたMyMethod
ClientFilter
ServerMethodsUnit
クライアントアプリケーションのフォームに 次に、ADataSource
と aDBGrid
を入れMyClientDs
て開きます。Tbutton
私はコードを入れましたOnClick
:
begin
MyClientDs .Close;
MyMethod .ParamByName('ID').Value := 5;
MyMethod .ExecuteMethod;
showmessage (MyMethod .ParamByName('ID').AsString);
// AT THIS POINT, returned value is ONE.
// I supposed that this Query had been filtered on
// the server and the client then show the filtered
// data, but it always shows the original query
MyClientDs .Close;
end;
DBGrid
The I see all records of Client Table, ALWAYS .
ClientTable
ボタンをクリックしてフィルターをかけてみましたが、DBGrid
常にすべてのレコードが表示されます。