GET TABLE RECORD COUNT IN XDATA AND WEB CORE

Hi Dears
I have problem with Txdatawebdataset in WebCore
when I load data
I need check record count of table directly after loading data
but Always it give to me zero "0" result
pls guide me

for example:

Txdatawebdataset1.load;
SHOWMESSAGE(INTTOSTR(Txdatawebdataset1.RecordCount));

Attention: If I check with another button after do
Txdatawebdataset1.load;
I will get a valid result

but if i do it directly after load
Txdatawebdataset.load;
SHOWMESSAGE(INTTOSTR(Txdatawebdataset1.RecordCount));

always result is "0"
.
.
.

I guess this could be an issue about async behaviour of Web-Requests. The data isn't immediately available after your command load.
I use record-count in the AfterOpen-Event of the dataset..

1 Like

yes , I know that "AfterOpen"
but I need do some code immediately after dataset.load command

Maybe this one helps...

https://www.tmssoftware.com/site/blog.asp?post=777

1 Like

Since Load is called asynchronously, there is no "code immediately" after it. It's asynchronous, you have to wait until it's completed and only then you can access the record count. Use the AfterOpen event.

ok , Thanks and Best Regards

HI DEAR
I DO THESE CODS IN AFTER OPEN
AND I HAVE DBRESPONSIVEGRID ON NEWFORM

procedure TMAINFORM.TGOODSMAfterOpen(DataSet: TDataSet);
var
newform: TFMENUSEARCH;
begin
If TGOODSM.RecordCount>0 then
BEGIN
newform := TFMENUSEARCH.CreateNew(procedure(AForm: TObject)
begin
// (AForm as TFMENUSEARCH).WRSP_SRCH.EventStopPropagation:=[];
end
);

    newform.Caption := 'Saft Kish';


        //used to manage Back button handling to close subform
    window.location.hash := 'search_goods';

    newform.ShowModal(procedure(AValue: TModalResult)
    begin
            //ShowMessage('Form 2 closed with new value:'+newform.frm2Edit.Text);
            //WebEdit1.Text := newform.frm2Edit.Text;
    end
    );
END;

end;

BUT WHEN FORM START SHOWING
MY CODES IN DBRESPONSIVEGRID.ONITEMCREATE
DO NOT WORK

procedure TFMENUSEARCH.WRSP_SRCHItemCreated(Sender: TObject;
Index: Integer);
begin
CurrencyString :='';

WRSP_SRCH.Items[index].ElementHandle.innerHTML:=
 '<div id="p'+INTTOSTR(MAINFORM.TGOODSM.RecNo)+'C" class="carousel slide" data-ride="carousel" style="width:150px;margin:auto;">'
+'<ol class="carousel-indicators">'
+'<li data-target="#p'+INTTOSTR(MAINFORM.TGOODSM.RecNo)+'C" data-slide-to="0" class="active"></li>'
+'<li data-target="#p'+INTTOSTR(MAINFORM.TGOODSM.RecNo)+'C" data-slide-to="1"></li>'
+'<li data-target="#p'+INTTOSTR(MAINFORM.TGOODSM.RecNo)+'C" data-slide-to="2"></li>'
+'</ol>'
+'<div class="carousel-inner" role="listbox">'
+'<div class="item active">'
+'<img width="145px" height="145" src="https://www.mahsantii.com/goods_img/'+TRIM(MAINFORM.TGOODSMPIC1.Value)+'_150.jpg">'
+'</div>'
+'<div class="item">'
+'<img width="145px" height="145" src="https://www.mahsantii.com/goods_img/'+TRIM(MAINFORM.TGOODSMPIC2.Value)+'_150.jpg">'
+'</div>'
+'<div class="item">'
+'<img width="145px" height="145" src="https://www.mahsantii.com/goods_img/'+TRIM(MAINFORM.TGOODSMPIC3.Value)+'_150.jpg">'
+'</div>'
+'</div>'
+'<a class="left carousel-control" href="#p'+INTTOSTR(MAINFORM.TGOODSM.RecNo)+'C" role="button" data-slide="prev">'
+'<span class="icon-prev" aria-hidden="true"></span>'
+'<span class="sr-only">Previous</span>'
+'</a>'
+'<a class="right carousel-control" href="#p'+INTTOSTR(MAINFORM.TGOODSM.RecNo)+'C" role="button" data-slide="next">'
+'<span class="icon-next" aria-hidden="true"></span>'
+'<span class="sr-only">Next</span>'
+'</a>'
+'</div>'
+'<P align="center">'
+'<br><B>'+TRIM(MAINFORM.TGOODSMCODS.Value)+'</B>'
+'<B>'+TRIM(MAINFORM.TGOODSMNAME.Value)+'</B> </P>';


If MAINFORM.TGOODSMDISCOUNT.Value>0 then
BEGIN
    WRSP_SRCH.Items[index].ElementHandle.innerHTML:=
    WRSP_SRCH.Items[index].ElementHandle.innerHTML
    +' <H5><P align="center"> '
    +' <small><DEL>'+FloatToStrF(MAINFORM.TGOODSMPRICE.Value, ffCurrency, 20, 0)+'</DEL></small>'
    +'  %'+FLOATTOSTR(MAINFORM.TGOODSMDISCOUNT.Value)+'</H5> '
    +' <H5><p align="center" class="text-danger"><B>'+'ر'+FloatToStrF(MAINFORM.TGOODSMPRICE.Value-ROUNDTO((MAINFORM.TGOODSMPRICE.Value*MAINFORM.TGOODSMDISCOUNT.Value/100),3), ffCurrency, 20, 0)+' ریال '+'</B></H5></P> '
    +' </P>';
END
ELSE
BEGIN
    WRSP_SRCH.Items[index].ElementHandle.innerHTML:=
    WRSP_SRCH.Items[index].ElementHandle.innerHTML
    +' <H5><P align="center" class="text-danger"> '
    +' <B>'+'ر'+FloatToStrF(MAINFORM.TGOODSMPRICE.Value, ffCurrency, 20, 0)+' ریال '+'</B> </H5>'
    +' </P>';
END;

end;

IN NORMAL CODES OUT OF AFTEROPEN
THESE CODES WORK CORECTLY

BUT I NEED DOING CODES AFTER CHECK RECORDCOUNT>0

PLEASE GUIDE ME.