You are not logged in.
Pages: 1
To read the data from the sever usually write:
Model := GetDatabaseModel;
Database:= TSQLRestClientDB.Create(Model, nil, filename, TSQLRestServerDB);
TSQLRestClientDB(Database).Server.CreateMissingTables(0);
....
procedure TForm1.LoadTempForUser(const AUser: TSQLUser;
const AList: TStrings);
var
Temp: TSQLTemp;
fIds: TIntegerDynArray;
begin
if AUser.Temp.SourceGet(Database, AUser.ID, fIds) then
begin
Temp:= TSQLTemp.CreateAndFillPrepare(Database, fIds);
AList.BeginUpdate();
AList.Clear();
try
while Temp.FillOne do
AList.AddObject(Format('%s', [UTF8ToString(Temp.Name)]), Pointer(Temp.id));
finally
AList.EndUpdate();
FreeAndNil(Temp);
end;
end
else
AList.Clear();
end;
but if someone changes the values in the table (Es:"temp") in the server, I does not know how to update data on the client side.
Offline
It sounds to me like I already answered to this question to you
http://synopse.info/forum/viewtopic.php?pid=1058#p1058
Or perhaps I'm misunderstanding.
Offline
Yes I can confirm, but it does not work, I created a table of relations between the user and the "temp" table and if I run the command
Database.UpdateFromServer ([temp.Users], refreshed) does not work
TSQLTemp = class(TSQLRecord)
private
...
fUsers: TSQLTempUsers;
published
...
property Users: TSQLTempUsers read fUsers;
end;
TSQLUser = class;
TSQLTempUsers = class(TSQLRecordMany)
private
fSource: TSQLTemp;
fDest: TSQLUser;
published
property Source: TSQLTemp read fSource;
property Dest: TSQLUser read fDest;
end;
// load list of Temp assigned to the given User
temp:= TSQLTemp.Create();
try
Database.UpdateFromServer ([temp.Users], refreshed);
temp.Users.SourceGet(Database, User.ID, clientsIds);
for i:= low(clientsIds) to high(clientsIds) do
begin
// find the client on the list (by ID)
for j:= 0 to CheckListBox1.Count -1 do
if Integer(CheckListBox1.Items.Objects[j]) = clientsIds[i] then
CheckListBox1.Checked[j]:= true;
end;
finally
temp.Free();
FreeAndNil(User);
end;
Probably I did not understand how it works the command "Database.UpdateFromServer" with the "TSQLRecordMany" tables
Offline
As far as I understand your code, you should use UpdateFromServer([temp]) instead.
You need to refresh the temp record, not the temp.Users record.
Then SouceGet() will create a dedicated SQL query, so it will work without need to refresh.
Offline
Sorry but maybe I have not explained,
I use sqlite Manager to view real-time changes in the temp table.
If I run the program and I execurte Database.Update (temp), and then I go to see sqlite Mangager I see new recorcd of temp.
Instead, if I run the program 2 times and one run an update, I see the change in sqlite manager and I can not see in the second program.
So I asked you how can I see the correct data from DB and you told me to use Database.UpdateFromServer ([temp], refreshed) but the data its not the same that I read by sqlite manager.Why?
Offline
I guess... you're not launching one server with two client, but instancing two server instances, with two associated clients...
If you're still using this code:
Model := GetDatabaseModel;
Database:= TSQLRestClientDB.Create(Model, nil, filename, TSQLRestClientDB);
TSQLRestClientDB(Database).Server.CreateMissingTables(0);
This is wrong for the client, because each TSQLRestClientDB creates its own TSQLRestClientDB instance.
This is only good for the server.
Offline
I do not use this configuration. Now I try to reduce my schedule for an example and try to send
Model := GetDatabaseModel;
Database:= TSQLRestClientDB.Create(Model, nil, filename, TSQLRestServerDB);
TSQLRestClientDB(Database).Server.CreateMissingTables(0);
Offline
How can I send you a sample of my program?
Offline
You should use Database := TSQLite3HttpClient.Create... from unit SQLite3HttpClient.pas to create the client.
Use some link tool like http://pastebin.mozilla.org/to send some code.
Offline
I can not send you a rar file?
Offline
Do I must create a program that makes a server?
Offline
Pages: 1