Mega Search
23.2 Million


Sign Up

Make a donation  
DataSnap - TIbQuery - Nested ClientDatasets - AMBIGUOUS resu  
News Group: embarcadero.public.delphi.database.multi-tier

Hi,

I had a project using the old midas multi-tier structure, I'm in the process of upgrading to the new DataSnap approach using Delphi Xe6.

In the remote server I have :

TMain_ServerContainer = class(TService) - Run as a windows service.....

7 - TDSServerClass Linked to 7 TDSServerModule (1 Main and 6 submodules)

1- Main_DSHTTPService: TDSHTTPService;
1- Main_DSAuthenticationManager: TDSAuthenticationManager;
1- Main_DSHTTPServiceProxyDispatcher: TDSHTTPServiceProxyDispatcher;
1- Main_DSProxyGenerator: TDSProxyGenerator;
1- Main_DSServerMetaDataProvider: TDSServerMetaDataProvider;
1- Main_DSHTTPServiceFileDispatcher: TDSHTTPServiceFileDispatcher;
1- Main_TCPServerTransport: TDSTCPServerTransport;

In the Main Server Method I have 2 IBDatabases and Transactions
To refer to the tables I use TIbQuery and TDataSetProvider

In the Client :

I Use as 7 DataModules Linked to the server using one TSqlConnection and 7 TDSProviderConnection (1 for each TDSServerClass).
And Of course tClientDataset

To connect to the server I use the TCP/IP Port, as it is (by now) set to use in a LAN network

THE PROBLEM:

Running some test I found a worrying behavior:

In the server, one of the subModules I Have a structure like this:

qrCountries - ProviderCountry - CountryDataSource 
qrCity_States Linked to CountryDataSource by CountryID and have - CityDataSource
qrSectors Linked to CityDataSource by CityID
qrZones Linked to CityDataSource by CityID


In the client :

tCountry - Set To ProviderCountry
tCity_States - Set DatasetField to qrCity_States
tSectors - Set DatasetField to qrSectors
tZones - Set DatasetField to qrZones 

Have another tcompany clientdataset wich holds a field Country and a field City 
In the countryvalidate event, I set the parameter CountryID for dataset tCountry to load the country, its cities, sectors and zones.

---- VALIDATION ----
procedure TModuloGenerales.tCompanyCountryValidate(Sender: TField);
begin
  tCountry.Close;
  tCountry.Params.ParamByName('CountryID').AsString := tCompanyCountry.Value;
  tCountry.Open;
end;
---- END VALIDATION ----


When It first load for country 'XXX', the result set brings The country, 155 cities and all the corresponding sectors and zones. OK

If I edit the country field for the same ID 'XXX' the result set brings: The country, 155 RECORDS but the data displayed on those records correspond only to the 2 last cities records of the tCity_States table, in the order:

City 154
City 155
City 154
City 155
City 154
City 155
until it reach 155 Records

If I edit the country field to another ID 'ZZZ' (wich has no cities) it brings the country and the empty tCity_States 
then I Edit to 'XXX' and the result set brings The country, 155 cities and all the corresponding sectors and zones. OK

I've changed bufferchunks on the tIBQuery
removed filters on the TDSTCPServerTransport
changed BufferKBSize on the TDSTCPServerTransport

nothing change this behavior....


Any IDEAS??? I've spended 4 days trying to solve this :'(

Vote for best question.
Score: 0  # Vote:  0
Date Posted: 18-Jul-2014, at 6:40 PM EST
From: Jose Carlos Gonzales
 
Re: DataSnap - TIbQuery - Nested ClientDatasets - AMBIGUOUS  
News Group: embarcadero.public.delphi.database.multi-tier
An Update:

1- I've copy the country, cities, states IBqueries to a stand-alone vcl form application; the database, the transaction, provider and the clientdatasets (so no datasnap involved) and everyting works ok. Then I think the bug must be in the comunication or data transport. but that's JUST a theory.

2- After doing the previous test, and debugging, and changin parameters, and a lot of other things I can't even remember...... I've Changed datasnap project in the tcompanycountry validation, so it now looks like this :

procedure TModuloGenerales.tcompanycountryValidate(Sender: TField);
begin
  if Not tCountry.Active then tCountry.Open;
  tCountry.Params.ParamByName('CountryID).AsString :=  tCompanyCountry.AsString;
  tCountry.Refresh;
end;

And It works OK, the data always comes the same.

ANY IDEAS???

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 20-Jul-2014, at 8:26 PM EST
From: Jose Carlos Gonzales