toufik 2 Posted May 1, 2021 (edited) hi every one can some one help me with problem I'm using Delphi REST with server and client but when i tried to show data on the client side its show only one row for some reason, what did i do wrong ? PS : I'm using Delphi roi and restdataware the video down show what I'm deal with ; any help will be very appreciated ^^ thank you on the client side i'm using this code procedure listv; var jsonObj : TJsonObject; json, sucesso, erro,id_store ,nom_store, phone_saler: string; begin // FrmLogin.FloatAnimation2.Stop; // FrmLogin.FloatAnimation3.Stop; if FrmLogin.listvreq.Response.JSONValue = nil then begin // FrmLogin.ExibirCampos; ShowMessage('خطأ في إنشاء الحساب (JSON غير صالح)'); exit; end; try json := FrmLogin.listvreq.Response.JSONValue.ToString; jsonObj := TJSONObject.ParseJSONValue(TEncoding.UTF8.GetBytes(json), 0) as TJSONObject; sucesso := jsonObj.GetValue('sucesso').Value; erro := jsonObj.GetValue('erro').Value; id_store := jsonObj.GetValue('id_store').Value; nom_store := jsonObj.GetValue('nom_store').Value; if sucesso <> 'S' then begin // FrmLogin.ExibirCampos; ShowMessage(erro); exit; end else // showmessage('تم احضار بيانات: ' + id_store+nom_store); // FrmLogin.ExibirCampos;/// // FrmLogin.ListView1.Items.Clear(); finally jsonObj.DisposeOf; end; end; procedure listverr(Sender: TObject); begin if Assigned(Sender) and (Sender is Exception) then begin // FrmLogin.ExibirCampos; showmessage(Exception(Sender).Message); end; end; procedure TFrmLogin.StartLogin2; begin TThread.CreateAnonymousThread( procedure var Success: Boolean; begin try RequestLogin.Execute; Success := RequestLogin.Response.Status.Success; except Success := False; end; TThread.Queue(nil, procedure begin AfterLogin2(Success); end ); end ).Start; end; procedure TFrmLogin.AfterLogin2(Success: Boolean); begin if Success then begin listvreq.Params.Clear; listvreq.AddParameter('type_store',ComboBox1.Selected.Text); /// **** listvreq.ExecuteAsync(listv, true, true, listverr); end else begin showmessage (' عفوا ...! لايمكن الاتصال بالخادم حاليا يرجى المحاولة لاحقا') end; on server side : procedure Tdm.DWEventsEventslistvReplyEvent(var Params: TDWParams; var Result: string); var type_store, erro : string; usuario : TUsuario; json : TJsonObject; begin try sleep(4000); type_store := Params.ItemsString['type_store'].AsString; json := TJsonObject.Create; usuario := TUsuario.Create(dm.conn); usuario.type_store := type_store; if NOT usuario.listv(erro) then begin //{"sucesso": "N", "erro":"Usuلrio nمo informado", "codusuario":"0"} json.AddPair('sucesso', 'N'); json.AddPair('erro', erro); json.AddPair('id_store', ''); json.AddPair('nom_store', ''); end else begin json.AddPair('sucesso', 'S'); json.AddPair('erro', ''); json.AddPair('id_store', usuario.id_store.ToString); json.AddPair('nom_store', usuario.nom_store); end; Result := json.ToString; finally json.DisposeOf; usuario.DisposeOf; end; and in class i add called unit usuario function TUsuario.listv(out erro: string): Boolean; var qry : TFDQuery; begin try qry := TFDQuery.Create(nil); qry.Connection := FConn; with qry do begin Active := false; SQL.Clear; SQL.Add('SELECT * from saler WHERE type_store = :any '); ParamByName('any').Value := type_store; Active := true; if RecordCount > 0 then begin id_store := FieldByName('id_store').AsInteger; nom_store := FieldByName('nom_store').AsString; erro := ''; Result := true; end else begin // id_store := 0; erro := 'تعذر جلب بيانات المعلنين'; Result := false; end; DisposeOf; end; except on ex:exception do begin erro := 'خطأ في التحقق من صحة تسجيل الدخول: ' + ex.Message; Result := false; end; end; bandicam_2021-05-01_17-50-29-913.mp4 Edited May 1, 2021 by toufik Share this post Link to post
eivindbakkestuen 47 Posted May 3, 2021 First, do some debugging and find out if the record "disappears" on the server side (query, or in the JSON transformation), or on the client side (store raw JSON, review contents...). 1 Share this post Link to post
toufik 2 Posted May 5, 2021 On 5/3/2021 at 5:38 AM, eivindbakkestuen said: First, do some debugging and find out if the record "disappears" on the server side (query, or in the JSON transformation), or on the client side (store raw JSON, review contents...). thanks for taking time to reply i found that i did not add an array , tjsonarray , that fix it for me Share this post Link to post