zqdl8 Posted May 25, 2023 Share Posted May 25, 2023 Hello everyone, may I ask how to set the value of a single cell in UniDBGrid using code? Thank you very much Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted May 25, 2023 Share Posted May 25, 2023 47 minutes ago, zqdl8 said: Hello everyone, may I ask how to set the value of a single cell in UniDBGrid using code? Thank you very much Hello, At the position on the UniDBGrid; 1. Not recommended method : MyDataSet.Edit; MyDataSet.FieldByName('myField_1').AsString:='Hello'; MyDataSet.Post; 2. Recommended Method : Use Transaction (as Unigui is a mult-Users application) : var Trans: TIBCTransaction; MyQuery:TIBCSQL; begin Trans := TIBCTransaction.Create(NIL); try Trans.DefaultConnection := C_Current; Trans.IsolationLevel := iblReadCommitted; Trans.StartTransaction; Screen.Cursor := crHourGlass; //======================== MyQuery:=TIBCSQL.Create(NIL); try MyQuery.Connection:=C_Current; MyQuery.Transaction:=Trans; txtSQL:='Update MyTable Set ' + ' MyField_1 = :MyField_1' + ' Where (ID = :ID)'; MyQuery.SQL.Clear; MyQuery.SQL.Add(txtSQL); if not MyQuery.Prepared then MyQuery.Prepare; With MyQuery do begin ParamByName('MyField_1').DataType :=ftWideString; ParamByName('MyField_1').AsWideString:='Hello'; ParamByName('ID').DataType :=ftinteger; ParamByName('ID').AsInteger :=MyDataSet.RecNo; end; MyQuery.Execute; finally MyQuery.Free; end; //======================== Trans.Commit; Screen.Cursor := crDefault; Except on E: Exception do begin erreur:=True; Trans.Rollback; ShowMessage(E.Message); end; end; finally Trans.Free; end; end; 1 Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted May 25, 2023 Share Posted May 25, 2023 44 minutes ago, zqdl8 said: Don't forget to Refresh Record : It reqires 3 things: MyDataSet.RefreshOptions:=[roAfterUpdate]; MyDataSet.RefreshRecord; UniDBGrid.RefreshCurrentRow(); Quote Link to comment Share on other sites More sharing options...
zqdl8 Posted May 25, 2023 Author Share Posted May 25, 2023 Perhaps I didn't express it very clearly earlier, what I meant was whether it is possible to do this. UndbGrid1.Cells[1, 1]:=xxxx; Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted May 25, 2023 Share Posted May 25, 2023 7 minutes ago, zqdl8 said: it is possible to do this. UndbGrid1.Cells[1, 1]:=xxxx; No, if it is possible in UniString, it's not for DBGrid : UnidbGrid1 is attached to a DataSet. So you have to work with DataSet. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 25, 2023 Share Posted May 25, 2023 27 minutes ago, Abaksoft said: if it is possible in UniString Yes, UniStringGrid. @zqdl8 Can you please specify which edition and build of uniGUI are you using? Quote Link to comment Share on other sites More sharing options...
zqdl8 Posted May 26, 2023 Author Share Posted May 26, 2023 12 hours ago, Sherzod said: Yes, UniStringGrid. @zqdl8 Can you please specify which edition and build of uniGUI are you using? uni-1.90.0.1564 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 26, 2023 Share Posted May 26, 2023 47 minutes ago, zqdl8 said: uni-1.90.0.1564 Not trial? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 28, 2023 Share Posted May 28, 2023 On 5/26/2023 at 9:04 AM, zqdl8 said: uni-1.90.0.1564 On 5/26/2023 at 9:52 AM, Sherzod said: Not trial? ? Quote Link to comment Share on other sites More sharing options...
zqdl8 Posted May 28, 2023 Author Share Posted May 28, 2023 9 minutes ago, Sherzod said: ? Not tria Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 28, 2023 Share Posted May 28, 2023 28 minutes ago, zqdl8 said: Not tria Please adjust your forum email address: Quote Link to comment Share on other sites More sharing options...
Stemon63 Posted May 29, 2023 Share Posted May 29, 2023 I think that Zqdl8 needs to assign the value into CLIENT, so dataset must be update automatically. I need the same: cell C = cell A + cell B, on the same row, at change of A or B; And I want to calculate it at Client level, so the dataset is update automatically at SERVER level on post. Otherwise too much "chatting" for a simple sum or row calculate. Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted May 29, 2023 Share Posted May 29, 2023 5 hours ago, Stemon63 said: so the dataset is update automatically at SERVER level You mean at Client Side ? Quote Link to comment Share on other sites More sharing options...
Stemon63 Posted May 29, 2023 Share Posted May 29, 2023 14 minutes ago, Abaksoft said: You mean at Client Side ? First immediately on the client and consequently then on the server Quote Link to comment Share on other sites More sharing options...
zqdl8 Posted May 29, 2023 Author Share Posted May 29, 2023 57 minutes ago, Stemon63 said: 首先立即在客户端上,然后在服务器上 right Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.