You are not logged in.
Pages: 1
I'm using the current source code for new VirtualTableExternalRegisterAll.
Right now I'm able to connect to MSSQL db server with a registered
VirtualTableExternal.
What I can't understand is how to register more than one external table
in the same Model to be able to use VirtualTableExternalRegisterAll.
Thanks!
Mauro
Offline
I can't understand how use VirtualTableExternal (with just one table, internal or external, everything works as expected).
This sample code doesn't work rising "exception class C0000005 with message: 'access violation at 0x0403dba...":
Var
aModel : TSQLModel;
aServer : TSQLRestServerDB;
aProps : TOleDBConnectionProperties;
//vRecord1 : TSQLA;
//vRecord2 : TSQLB;
begin
aModel : CreateTestData;
aModel.VirtualTableRegister(TSQLA, TSQLVirtualTableJSON);
aModel.VirtualTableRegister(TSQLB, TSQLVirtualTableJSON);
aServer : TSQLRestServerDB.Create(aModel,'db.db3',false);
aServer.CreateMissingTables();
TSQLite3HttpServer.Create('8080',[aServer]);
WriteLn('Press ENTER to Exit');
ReadLn;
end.
//---------------------------- interface file
type
TSQLA = class(TSQLRecordVirtualTableAutoID)
private
ffield1: Integer;
ffield2: RawUTF8;
published
property field1: Integer read ffield1 write ffield1;
property field2: RawUTF8 read ffield2 write ffield2;
end;
type
TSQLB = class(TSQLRecordVirtualTableAutoID)
private
ffield3: Integer;
ffield4: RawUTF8;
published
property field3: Integer read ffield3 write ffield3;
property field4: RawUTF8 read ffield4 write ffield4;
end;
function CreateTestData: TSQLModel;
implementation
function CreateTestData: TSQLModel;
begin
result : TSQLModel.Create([TSQLA, TSQLB], 'root');
end;
Thanks for your help!
Offline
It's a CONSOLE application so when you compile it with the second VirtualTableRegister activated the program crash and close the window.
The exact error message is:
Project Project1.exe raised exception class C0000005 with message 'access violation at 0x00403dba: read of address 0xbaadf00d'.
Process stopped. Use Step or Run to continue.
Here the test source I'm using:
------------------------Project1.dpr----------------------
program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils,
SynCommons,
SynOleDB,
SynDB,
SQLite3Commons,
SQLite3,
SQLite3DB,
SQLite3HttpServer,
Unit1 in 'Unit1.pas';
Var
aModel : TSQLModel;
aServer : TSQLRestServerDB;
Server: TSQLite3HttpServer;
begin
aModel := CreateMyModel;
// The program compile and run correctly if you
// comment out one of these lines
aModel.VirtualTableRegister(TSQLA, TSQLVirtualTableJSON);
aModel.VirtualTableRegister(TSQLB, TSQLVirtualTableJSON);
aServer := TSQLRestServerDB.Create(aModel,'database.db3',false);
aServer.CreateMissingTables();
Server := TSQLite3HttpServer.Create('8080',[aServer]);
WriteLn('Press ENTER to Exit');
ReadLn;
end.
-----------------Unit1.pas-----------------------
unit Unit1;
interface
uses
SynCommons,
SQLite3Commons;
type
TSQLA = class(TSQLRecord)
private
fFirstField : Integer;
fSecondField: RawUTF8;
published
property FirstField: Integer read fFirstField write fFirstField;
property SecondField: RawUTF8 read fSecondField write fSecondField;
end;
type
TSQLB = class(TSQLRecord)
private
fThirdField : Integer;
fFourthField: RawUTF8;
published
property ThirdField: Integer read fThirdField write fThirdField;
property FourthField: RawUTF8 read fFourthField write fFourthField;
end;
function CreateMyModel: TSQLModel;
implementation
function CreateMyModel: TSQLModel;
begin
result := TSQLModel.Create([TSQLA, TSQLB]);
end;
end.
Offline
Pages: 1