Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread Unable to save data
Fri, Sep 27 2019 1:12 AMPermanent Link

KimHJ

Comca Systems, Inc

I'm unable to find out why this will not save or update the table, I get no errors and I added show message in the code an at no point is it exiting the procedure. I even moved the whole procedure to the data unit, but no luck. I have other tables that update and insert with no problems using the same formula. Only the Buttonnum is required in the table.

Using the latest version of EWB and EDB.

procedure TDataM.ButtonTblLoad;
begin
  LoadRows(ButtonTbl);
end;

procedure TDataM.ButtonTblAfterLoad(Sender: TObject);
begin
   ButtonTbl.Open;
end;

procedure TDataM.UpdateButton(ButToUp:Integer);
var
MyColor: TColor;
ButtonNumber: String;
begin
     // DataM.StartTransaction;
     with ButtonTbl do
                 begin
                    ButtonNumber:=IntToStr(ButToUp);
                    Columns['Buttonnum'].SortDirection:=sdAscending;
                    SortCaseInsensitive:=True;
                    Sort;
                    InitFind;
                    Columns['Buttonnum'].AsInteger := ButToUp;
                    if Find(False,True) then
                       begin
                          Update;
                       end
                    else
                       begin
                          DataM.ButtonTbl.Insert;
                          Columns['Buttonnum'].AsString := ButtonNumber;
                       end;

                    TCaptionPanel(ButtonSetForm.FindComponent('Item' + ButtonNumber)).Caption := PriceTbl.Columns['NameButton'].AsString;
                    Columns['Name'].AsString := DataM.PriceTbl.Columns['Name'].AsString;
                    Columns['NameButton'].AsString := PriceTbl.Columns['NameButton'].AsString;
                    Columns['Productnum'].AsString := PriceTbl.Columns['Productnum'].AsString;
                    Columns['ButtonH'].AsInteger := 0;
                    Columns['ButtonW'].AsInteger := 0;
                    //update color and font

                    MyColor := TCaptionPanel(ButtonSetForm.FindComponent('Item' + ButtonNumber)).Background.Fill.Color;
                    Columns['ButtonColor'].AsInteger := Integer(MyColor);
                    Columns['ButtonFontSize'].AsInteger := TCaptionPanel(ButtonSetForm.FindComponent('Item' + ButtonNumber)).Font.Size;
                    if TCaptionPanel(ButtonSetForm.FindComponent('Item' + ButtonNumber)).Font.Style.Bold then
                       Columns['ButtonFontBold'].AsBoolean := True;
                    MyColor := TCaptionPanel(ButtonSetForm.FindComponent('Item' + ButtonNumber)).Font.Color;
                    Columns['ButtonFontColor'].AsInteger := Integer(MyColor);

                    Save;   
                 end;
      // DataM.Commit;
end;

Anything wrong with this code?
Kim
Fri, Sep 27 2019 5:00 AMPermanent Link

Walter Matte

Tactical Business Corporation

Use Fiddler to see any traffic between your EWB program and your server.


You do not need to open the table in the AfterLoad event.  It is open.  You can check the State property to see that.

Is the DataModule set to AutoTransactions := True?  

Since you commented out the StartTransaction and Commit - then I assume you set AutoTransactions to True.

Also is the DataModule BaseURL set to where it needs to be for your environment?

Where is UpdateButton Called?



Walter


KimHJ wrote:

I'm unable to find out why this will not save or update the table, I get no errors and I added show message in the code an at no point is it exiting the procedure. I even moved the whole procedure to the data unit, but no luck. I have other tables that update and insert with no problems using the same formula. Only the Buttonnum is required in the table.

Using the latest version of EWB and EDB.

procedure TDataM.ButtonTblLoad;
begin
  LoadRows(ButtonTbl);
end;

procedure TDataM.ButtonTblAfterLoad(Sender: TObject);
begin
   ButtonTbl.Open;
end;

procedure TDataM.UpdateButton(ButToUp:Integer);
var
MyColor: TColor;
ButtonNumber: String;
begin
     // DataM.StartTransaction;
     with ButtonTbl do
                 begin
                    ButtonNumber:=IntToStr(ButToUp);
                    Columns['Buttonnum'].SortDirection:=sdAscending;
                    SortCaseInsensitive:=True;
                    Sort;
                    InitFind;
                    Columns['Buttonnum'].AsInteger := ButToUp;
                    if Find(False,True) then
                       begin
                          Update;
                       end
                    else
                       begin
                          DataM.ButtonTbl.Insert;
                          Columns['Buttonnum'].AsString := ButtonNumber;
                       end;

                    TCaptionPanel(ButtonSetForm.FindComponent('Item' + ButtonNumber)).Caption := PriceTbl.Columns['NameButton'].AsString;
                    Columns['Name'].AsString := DataM.PriceTbl.Columns['Name'].AsString;
                    Columns['NameButton'].AsString := PriceTbl.Columns['NameButton'].AsString;
                    Columns['Productnum'].AsString := PriceTbl.Columns['Productnum'].AsString;
                    Columns['ButtonH'].AsInteger := 0;
                    Columns['ButtonW'].AsInteger := 0;
                    //update color and font

                    MyColor := TCaptionPanel(ButtonSetForm.FindComponent('Item' + ButtonNumber)).Background.Fill.Color;
                    Columns['ButtonColor'].AsInteger := Integer(MyColor);
                    Columns['ButtonFontSize'].AsInteger := TCaptionPanel(ButtonSetForm.FindComponent('Item' + ButtonNumber)).Font.Size;
                    if TCaptionPanel(ButtonSetForm.FindComponent('Item' + ButtonNumber)).Font.Style.Bold then
                       Columns['ButtonFontBold'].AsBoolean := True;
                    MyColor := TCaptionPanel(ButtonSetForm.FindComponent('Item' + ButtonNumber)).Font.Color;
                    Columns['ButtonFontColor'].AsInteger := Integer(MyColor);

                    Save;   
                 end;
      // DataM.Commit;
end;

Anything wrong with this code?
Kim
Fri, Sep 27 2019 7:59 AMPermanent Link

Matthew Jones

Walter Matte wrote:

> Use Fiddler to see any traffic between your EWB program and your server.


Or use Chrome or other browser developer tools, which should give you everything relevant without any extras.
--

Matthew Jones
Fri, Sep 27 2019 10:44 PMPermanent Link

KimHJ

Comca Systems, Inc

Walter Matte wrote:

> Use Fiddler to see any traffic between your EWB program and your server.


> Or use Chrome or other browser developer tools, which should give you everything relevant without any extras.

Walter this is my development computer I'm using the Internal Web Server and running it from the IDE. I have AutoTransaction set to True, I added start and commit to see if it would help, but it didn't. I have other tables in the database that works fine. I removed the table and added it again.

I have added ShowMessage the whole way down adding every single data in the showmessage and it goes to save and after save.

I installed Fiddler and in the commit I see this: { "operations": [ ] }
When I commit other Tables I see all the rows in the operation.

Kim
Fri, Sep 27 2019 11:26 PMPermanent Link

KimHJ

Comca Systems, Inc

I deleted the PriceTbl from the dataunit and from the Database Manger and added it back in. Now the ButtonTbl is inserting and updating, but the PriceTbl no longer shows in my grid even the Pricetbl is set as the Dataset.

When I add the Grid on the form and add the dataset all column headers shows in the grid.

Fixed one broke another.

Kim
Fri, Sep 27 2019 11:45 PMPermanent Link

KimHJ

Comca Systems, Inc

I got it to work by leaving the Grid Dataset blank and then OnShow add the following lines:

Grid1.DataSet := DataM.PriceTbl;
Grid1.AddColumnsFromDataSet;

Kim
Mon, Sep 30 2019 4:55 AMPermanent Link

Matthew Jones

KimHJ wrote:

> I have added ShowMessage the whole way down

The better way is to have a multi-line edit box, and append messages to that. Then it won't interfere with the general asynchronous flow. If you get fancy, just add messages to a TStringList and then update the edit on a timer if something has been added.

--

Matthew Jones
Image