You are not logged in.
Pages: 1
Hi,
I test Mormot to use it on a existing project.
We need to use a ORM connected with Firedac (On Oracle, MSSQL, ACCESS, Postresql) on an standalone software.
So i have test many samples and read the documentation and code this for the test :
SampleData.pas
TSQLSampleRecord = class(TSQLRecord)
private
fQuestion: String;
fName: String;
fTime: TDateTime;
fColor : TColor;
published
property Timetest: TDateTime read fTime write fTime;
property Name: String read fName write fName;
property Question: String read fQuestion write fQuestion;
property Color : TColor read fColor write fColor;
end;
function CreateSampleModel: TSQLModel;
implementation
function CreateSampleModel: TSQLModel;
begin
result := TSQLModel.Create([TSQLSampleRecord]);
end;
my FormMain :
procedure TForm1.FormCreate(Sender: TObject);
begin
Model := CreateSampleModel; // from SampleData unit
aProps := TSQLDBFireDACConnectionProperties.Create(FIREDAC_PROVIDER[dJet] , 'C:\Users\Dev\Desktop\mORMot-master\SQLite3\Samples\01 - In Memory ORM\test.mdb' , '' , '');
VirtualTableExternalRegisterAll(Model,aProps);
Database := TSQLRestServerDB.Create(Model, ':memory:' ,false);
TSQLRestServerDB(Database).CreateMissingTables;
end;
procedure TForm1.AddButtonClick(Sender: TObject);
var Rec: TSQLSampleRecord;
begin
Rec := TSQLSampleRecord.Create;
try
// we use explicit StringToUTF8() for conversion below
// a real application should use TLanguageFile.StringToUTF8() in mORMoti18n
Rec.Name := NameEdit.Text;
Rec.Question := QuestionMemo.Text;
Rec.Timetest := Now;
Rec.Color := clgray;
if Database.Add(Rec,true)=0 then
ShowMessage('Error adding the data') else begin
NameEdit.Text := '';
QuestionMemo.Text := '';
NameEdit.SetFocus;
end;
finally
Rec.Free;
end;
end;
The connection to the DB via Firedac is OK, the CreateMissingTables do is job on my Access base.
But the Database.Add() Create a Project1.db and save the SQLSampleRecord in this file with json format. (And only when i close the application)
I have take the "01 - In Memory ORM" Sample to start this test.
If i code this instead :
Database := TSQLRestServerDB.Create(Model, 'C:\Users\Dev\Desktop\mORMot-master\SQLite3\Samples\01 - In Memory ORM\test.mdb' ,false);
I have this error : SQLLITE_NOTADB: File is encrypted or is not a database.
have somebody an idea?
Thank's for your help.
Pages: 1