I have DLL that has functions to be performed on the TClientDataSet like set file to be loaded and loading and saving of file.
unit dll_dmunit;
interface
uses
System.SysUtils, System.Classes, Data.DB, Datasnap.DBClient, Vcl.Dialogs,Vcl.DBGrids;
type
TStudentModule = class(TDataModule)
StudentSet: TClientDataSet;
StudentSource: TDataSource;
StudentSetNAME: TStringField;
StudentSetID: TIntegerField;
StudentSetAGE: TIntegerField;
StudentSetSLNo: TAutoIncField;
dlgOpen: TOpenDialog;
dlgSave: TSaveDialog;
private
{ Private declarations }
public
end;
function loadfile:tdbgrid;stdcall;
procedure setfile(fname:string);stdcall;
procedure savefile;stdcall;
var
StudentModule: TStudentModule;
filename:string;
grid:TDBgrid;
const
path:string='C:\Users\GlobalLogic\Documents\RAD Studio\Projects\Student\test.cds';
implementation
{%CLASSGROUP 'Vcl.Controls.TControl'}
{$R *.dfm}
procedure setfile(f_name: string);stdcall;
begin
filename:=f_name;
end;
function loadfile:tdbgrid;stdcall;
var
_xmldata:string;
begin
StudentModule := TStudentModule.Create(nil);
grid:=TDBGrid.Create(nil);
result:=grid;
try
filename:='C:\Users\GlobalLogic\Documents\RAD Studio\Projects\Student\test.cds';
StudentModule.StudentSet.LoadFromFile(filename);
grid.DataSource:=StudentModule.StudentSource;
_xmldata :=StudentModule.StudentSet.XMLData;
result:=grid;
finally
StudentModule.Free;
end;
showmessage('End of the function');
end;
procedure savefile;stdcall;
begin
StudentModule.StudentSet.SaveToFile(filename);
end;
end.
I am able to perform the loadfile method, but now I need to export the content of the TClientDataSet to the Delphi application. For that I am trying to get the content in a TDbgrid and then return this object to application layer, but I am unable to do so. Then I tried to read in XML format but couldn't understand how to pass and decode the XML format. I need to move the content of the loaded dataset to my application where I want to display the data. Please help me in doing so. Thank You