#1 2016-11-18 11:49:24

mrauter
Member
Registered: 2016-11-18
Posts: 4

Mapping TSqlRecord to existing MS Sql table not working?

Hello,

First of all, thanks for the amazing work. The Mormot Framework is amazing and it is looking perfect for my needs.

I am trying to map an TSQLRecord inhereted class to an external MS Sql table, but I just can't make it work.

  aProps := TOleDBMSSQLConnectionProperties.Create('192.168.2.30','homologacao319','studio_fiscal','sf@2012!@#$');
  try
    aModel := TSQLModel.Create([TJob],SERVER_ROOT);

    VirtualTableExternalMap(aModel, TJob, aProps, 'dbo.PROJECT_QBERT_JOBS').
      MapField('ID', 'Job').
      MapField('Cliente', 'codigo_cliente').
      MapField('Franqueado', 'CODIGO_FRANQUEADO').
      MapField('Produto', 'CODIGO_PRODUTO').
      MapField('DataCadastro', 'DATA_CADASTRO');

    try
      aRestServer := TSQLRestServerDB.Create(aModel,'application.db',false); // authentication=false
      try
        Job:= TJOB.CreateAndFillPrepare(aRestServer, '');
  TJob = class(TSQLRecord) // TSQLRecord has already ID: integer primary key
  private
    fJob: Integer;
    fCliente: Integer;
    fFranqueado: Integer;
    fProduto: Integer;
    fDataCadastro: TDateTime;
  published
    /// ORM will create a NAME VARCHAR(80) column
    property Job: Integer read fJob write fJob;
    property Cliente: Integer read fCliente write fCliente;
    property Franqueado: Integer read fFranqueado write fFranqueado;
    property Produto: Integer read fProduto write fProduto;
    property DataCadastro: TDateTime read fDataCadastro write fDataCadastro;
  end;

At this line" Job:= TJOB.CreateAndFillPrepare(aRestServer, ''); " the following exception occurs:
First chance exception at $749CA6F2. Exception class ESQLite3Exception with message 'Error SQLITE_ERROR (1) [SELECT RowID,Job,Cliente,Franqueado,Produto,DataCadastro FROM Job] using 3.15.1 - no such table: Job, extended_errcode=1'. Process MoemorTest.exe (16808)

The correct sql syntax should be 'SELECT Job,codigo_cliente,CODIGO_FRANQUEADO,CODIGO_PRODUTO,DATA_CADASTRO FROM PROJECT_QBERT_JOBS'.

I've read good chunks of the documentation (which is very good btw) to no avail, I am probably missing something. What is it?

Last edited by mrauter (2016-11-18 17:03:31)

Offline

Board footer

Powered by FluxBB