#1 2014-08-21 10:39:11

muabbet
Member
Registered: 2014-08-20
Posts: 4

Mormot framework Firedac (Firebird) Connection Help

How can i get Customer list to dbgrid?
How can i get Selected record in dbgrid ?
How can i add new customer and get last id from generator?

TYPE
  TSQLCustomer = class(TSQLRecord)
  private
    fCUSTOMERID:INTEGER;
    fCUSTOMERCODE: RawUTF8;
    fNAME: RawUTF8;
  published
    property CUSTOMERID: INTEGER read fCUSTOMERID write fCUSTOMERID;
    property CUSTOMERCODE: RawUTF8 read fCUSTOMERCODE write fCUSTOMERCODE;
    property NAME: RawUTF8 read fNAME write fNAME;
  end;

procedure TForm1.Button1Click(Sender: TObject);
VAR
tcustomer :TSQLcustomer;
FCONNECTION:TSQLDBFireDACConnectionProperties;
fcon:TSQLDBFireDACConnection;
fModel: TSQLModel;
fClient: TSQLRestClientDB;
dbserver:TSQLRestServerDB;
table: TSQLTable;
TN:TRawUTF8Array;
  I: Integer;
begin
TFDPhysFBDriverLink.Create(Application).VendorLib := ExtractFilePath(Application.ExeName)+'fbclient.dll';
fconnection := TSQLDBFireDACConnectionProperties.Create(FIREDAC_PROVIDER[dFirebird],'E:\depo\DELPHI_XE5\kodlar\HalStokluFirebird\2014\DATABASE.fdb','SYSDBA','masterkey'); 
FCON:=TSQLDBFireDACConnection.Create(FCONNECTION);
FCON.Connect; 
//CONNECTİON SUCCESS
fModel := TSQLModel.Create([TSQLcustomer]);
VirtualTableExternalRegister(fModel, TSQLcustomer, fConnection, 'customer');
//HELP CREATE DBSERVER  CODE AND GET CUSTOMERLIST to dbgrid(datasource)

END;

Offline

#2 2014-08-21 13:09:24

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,232
Website

Re: Mormot framework Firedac (Firebird) Connection Help

Some points:

1. There is already an ID: integer field at TSQLRecord level,  which is the primary key.
So there is no need to add a "CustomerID" field.

2. Your code does not relase any memory, so all your process should better be encapsulated in a dedicated class (see point 5).
It mixes client and server code, which is not a good practice.
You are creating a connection, which is not necessary for external databases.
So I'm afraid you would have to put your whole code in the trash.

3. Please see the available samples, and start from something existing, for your client and server part.
For instance https://github.com/synopse/mORMot/tree/ … M%20Server
It is just what you need - to access PostgreSQL, but you can just change the connection properties to use FireBird instead.

4. You would not be able to use a DBGrid directly, unless you use mORMotVCL to create a TDataSource.
See https://github.com/synopse/mORMot/tree/ … aset%20use

5. Ensure you read at least the chapters about REST Client-Server, ORM, and External Databases in the SAD 1.18 pdf, and did see, compile and test all the samples.
Please, forget about RAD (use it only for the UI), and try to write a clean application, separating the UI from the Logic.

Offline

#3 2014-08-21 13:44:59

muabbet
Member
Registered: 2014-08-20
Posts: 4

Re: Mormot framework Firedac (Firebird) Connection Help

Thanks for advice

Offline

Board footer

Powered by FluxBB