Delphi Datasnap send ClientDataSet to Server using tcp/ip -
i have simple datasnap tcp/ip based client server application. created clientdataset on client application , filled data. how can send clientdataset records server can process , save data server.
edited
so tried below code, problem @ server getting 1 less record sending client
client code
var cd: tclientdataset; begin cd:= tclientdataset.create(self); cd.data := cdscustomer.data; memo1.lines.add(inttostr( cd.recordcount )) ; servermethods1client.testdataset( cd);
server code
function tservermethods1.testdataset(ds: tdataset): string; begin try datasetprovidercommon.dataset := ds; if not datasetprovidercommon.dataset.eof tempclientdataset.open; if tempclientdataset.recordcount >0 form1.memo1.lines.add( inttostr( tempclientdataset.recordcount) ) else form1.memo1.lines.add( ' not records found' ) ; datasetprovidercommon.dataset.close; except on e: exception form1.memo1.lines.add('testdataset error :' + e.message ) ; end; end;
you can pass data property server olevariant type (likewise can pass data server client using olevariant result type or var/out parameters):
client code
begin memo1.lines.add( inttostr( cdscustomer.recordcount ) ); servermethods1client.testdataset( cdscustomer.data ); end;
server code
function tservermethods1.testdataset(ds: olevariant): string; begin try tempclientdataset.data := ds; if tempclientdataset.recordcount > 0 form1.memo1.lines.add( inttostr( tempclientdataset.recordcount ) ) else form1.memo1.lines.add( 'no records found' ) ; tempclientdataset.close; except on e: exception form1.memo1.lines.add( 'testdataset error: ' + e.message ); end; end;
Comments
Post a Comment