powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Delphi [игнор отключен] [закрыт для гостей] / DataSnap. Прошу промощи
3 сообщений из 3, страница 1 из 1
DataSnap. Прошу промощи
    #39560190
bastibubu
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
создаю DataSnap трёхзвенку. Delphi 10.2, firebird 3
использую методы сервера.
связка на сервере: sqlConnection-->sqlprovider-->sqldataset или sqlQuery
связка на клиенте: ServerMethod-->datasetProvider-->Clientdataset-->datasource

на ServerMethods1:
Код: pascal
1.
2.
3.
sqlConnection1: Driver firebird, 
datasetprovider.dataset=dsetSelectCountry( sqldataset компонент)
dsetSelectCountry.connection=sqlConnection1.



на ClientModule1:
Код: pascal
1.
2.
3.
4.
servermethodSelectCountry.servermethodname=TServerMethods1.SelectCountry
datasetproviderSelectCountry.dataset=servermethodSelectCountry
clientdatasource.SelectCountry.ProviderName=datasetProviderSelectCountry
datasource.dataset=clientdatasetSelectCountry. 



Код: pascal
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
unit ClientClassesUnit1;

type
  TServerMethods1Client = class(TDSAdminClient)
  private
    FEchoStringCommand: TDBXCommand;
    FReverseStringCommand: TDBXCommand;
    FSelectPriceCommand: TDBXCommand;
    FUpdatePriceCommand: TDBXCommand;
    FSelectCountryCommand: TDBXCommand;
  public
   ...................
    function EchoString(Value: string): string;
    function ReverseString(Value: string): string;
    procedure SelectPrice;
    procedure UpdatePrice(Das: string; Firmcode: Integer; Pr_id: Integer);
    procedure SelectCountry;
  end;

implementation
.......
procedure TServerMethods1Client.SelectCountry;
begin
  if FSelectCountryCommand = nil then
  begin
    FSelectCountryCommand := FDBXConnection.CreateCommand;
    FSelectCountryCommand.CommandType := TDBXCommandTypes.DSServerMethod;
    FSelectCountryCommand.Text := 'TServerMethods1.SelectCountry';
    FSelectCountryCommand.Prepare;
  end;
  FSelectCountryCommand.ExecuteUpdate;
end;


procedure TServerMethods1Client.UpdatePrice(Das: string; Firmcode: Integer; Pr_id: Integer);
begin
  if FUpdatePriceCommand = nil then
  begin
    FUpdatePriceCommand := FDBXConnection.CreateCommand;
    FUpdatePriceCommand.CommandType := TDBXCommandTypes.DSServerMethod;
    FUpdatePriceCommand.Text := 'TServerMethods1.UpdatePrice';
    FUpdatePriceCommand.Prepare;
  end;
  FUpdatePriceCommand.Parameters[0].Value.SetWideString(Das);
  FUpdatePriceCommand.Parameters[1].Value.SetInt32(Firmcode);
  FUpdatePriceCommand.Parameters[2].Value.SetInt32(Pr_id);
  FUpdatePriceCommand.ExecuteUpdate;
end;

.....
end;



первый запрос insert: sqldatasetSelectCountry.commandtext='select * from country'.

клик на кнопке в clientunit:
Код: pascal
1.
2.
3.
4.
5.
6.
7.
8.
procedure Tclient.BSelectCountryClick(Sender: TObject);
begin
Clientmodule1.smSelectCountry.ServerMethodName:='TServerMethods1.SelectCountry';
Clientmodule1.smSelectCountry.ExecuteMethod;

Clientmodule1.cdsSelectCountry.close;
Clientmodule1.cdsSelectCountry.Open;
end;



в ClientClasses:
Код: pascal
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
procedure TServerMethods1Client.SelectCountry;
begin
  if FSelectCountryCommand = nil then
  begin
    FSelectCountryCommand := FDBXConnection.CreateCommand;
    FSelectCountryCommand.CommandType := TDBXCommandTypes.DSServerMethod;
    FSelectCountryCommand.Text := 'TServerMethods1.SelectCountry';
    FSelectCountryCommand.Prepare;
  end;
  FSelectCountryCommand.ExecuteUpdate;
end;



в ServermethodsUnit:
Код: pascal
1.
2.
3.
4.
5.
6.
procedure TServerMethods1.SelectCountry;
begin
  sqlconnectionServer.Close;
  sqlconnectionServer.Open;
  dsetSelectCountry.Open;
end;



при клике на кнопке не заходит в clientclassesunit в методе SelectCountry и выводит ошибку
Код: sql
1.
error: servermethodSelectCountry: cursor nort returned from query.



аналогично на второй update запрос:
Код: sql
1.
sqldatasetSelectCountry.commandtext='update price set das=:das  and firmcode=:firmcode where pr_id=:pr_id'.



бд и проект в Zip
...
Рейтинг: 0 / 0
DataSnap. Прошу промощи
    #39560207
Фотография X-Cite
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Может попробовать ?
Код: pascal
1.
2.
3.
4.
5.
6.
7.
function TServerMethods1.SelectCountry: TDataSet;
begin
  sqlconnectionServer.Close;
  sqlconnectionServer.Open;
  dsetSelectCountry.Open;
  Result := dsetSelectCountry;
end;
...
Рейтинг: 0 / 0
DataSnap. Прошу промощи
    #39560222
bastibubu
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
X-Cite, ура заработал! Вы супер!
Хотя, честно говоря, больше вопросов появились. Если сможете помочь буду благодарен:
1) в примере Embarcadero "ReverseString" после оператора
Код: pascal
1.
Edit1.Text := ClientModule1.ServerMethods1Client.ReverseString(Edit1.Text);


контрол переходит в функции
Код: pascal
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
function TServerMethods1Client.ReverseString(Value: string): string;
begin
  if FReverseStringCommand = nil then
  begin
    FReverseStringCommand := FDBXConnection.CreateCommand;
    FReverseStringCommand.CommandType := TDBXCommandTypes.DSServerMethod;
    FReverseStringCommand.Text := 'TServerMethods1.ReverseString';
    FReverseStringCommand.Prepare;
  end;
  FReverseStringCommand.Parameters[0].Value.SetWideString(Value);
  FReverseStringCommand.ExecuteUpdate;
  Result := FReverseStringCommand.Parameters[1].Value.GetWideString;

end; 



а у меня после операторов
Код: pascal
1.
2.
3.
4.
5.
6.
7.
8.
procedure Tclient.BSelectCountryClick(Sender: TObject);
begin
Clientmodule1.smSelectCountry.ServerMethodName:='TServerMethods1.SelectCountry';
Clientmodule1.smSelectCountry.ExecuteMethod;

Clientmodule1.cdsSelectCountry.close;
Clientmodule1.cdsSelectCountry.Open;
end;


не заходит в модуле классов клиента clientclassesunit1.

2) Что такое Result? Где он возврашает значение?

3)
есть второй апдейт-запрос:
Код: pascal
1.
qUpdatePrice.sql='update price set das=:das  and firmcode=:firmcode where pr_id=:pr_id'



на клиенте при запушенной программе последный из этих 4-х операторов вызивает вызивает access violation:

Код: pascal
1.
2.
3.
4.
5.
6.
7.
procedure Tclient.BUpdatePriceClick(Sender: TObject);
begin
Clientmodule1.smUpdatePrice.Params.ParamByName('Pr_k').Value:=100;
Clientmodule1.smUpdatePrice.Params.ParamByName('das').Value:='aaa';
Clientmodule1.smUpdatePrice.Params.ParamByName('firmcode').Value:=5;
Clientmodule1.smUpdatePrice.ExecuteMethod;
end;


а в дизаинере при попитке присвайвать servermodule и clientdataset active:=true получаю error:
Код: pascal
1.
remote error:conversion error from string " "



связка sqlconnection1-->servermethod--> datasetprovider-->clientdataset как-будто правильно построена.
...
Рейтинг: 0 / 0
3 сообщений из 3, страница 1 из 1
Форумы / Delphi [игнор отключен] [закрыт для гостей] / DataSnap. Прошу промощи
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]