You've already forked lazarus-ccr
TvPlanIt: Extended ZEOS datastore sample to show usage of a Firebird database.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8254 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
15
components/tvplanit/examples/datastores/zeos/readme.txt
Normal file
15
components/tvplanit/examples/datastores/zeos/readme.txt
Normal file
@ -0,0 +1,15 @@
|
||||
This demo shows how the ZeosLib components can be used for VisualPlanIt. It
|
||||
takes advantage of the prebuilt TVpZeosDatastore.
|
||||
|
||||
The test application was tested for sqlite3 and FireBird (v3) databases. In the
|
||||
header of unit1.pas there are conditional defines to select the database type;
|
||||
activate ONE of them.
|
||||
|
||||
Firebird is tested only for v3.
|
||||
|
||||
Login parameters for the created Firebird database:
|
||||
username: SYSDBA
|
||||
password: masterkey
|
||||
|
||||
NOTE:
|
||||
The project creates a new database on the fly using these login parameters.
|
@ -2,13 +2,18 @@ unit Unit1;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
// Activate ONE of the following defines for the database system to be used:
|
||||
|
||||
{$DEFINE sqlite3}
|
||||
{.$DEFINE firebird3}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
|
||||
StdCtrls, ComCtrls, VpBaseDS, VpZeosDs, VpDayView, VpWeekView, VpTaskList,
|
||||
VpContactGrid, VpMonthView, VpResEditDlg, VpContactButtons, ZConnection,
|
||||
ZDataset;
|
||||
ZDataset, ZDbcIntfs;
|
||||
|
||||
type
|
||||
|
||||
@ -57,7 +62,12 @@ uses
|
||||
LazFileUtils;
|
||||
|
||||
const
|
||||
{$IFDEF sqlite3}
|
||||
DBFILENAME = 'data.db';
|
||||
{$ENDIF}
|
||||
{$IFDEF firebird3}
|
||||
DBFILENAME = 'data.fdb';
|
||||
{$ENDIF}
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
@ -77,15 +87,36 @@ end;
|
||||
// Setting up the database connection and the datastore. Preselect a resource
|
||||
// in the resource combo.
|
||||
procedure TForm1.FormCreate(Sender: TObject);
|
||||
var
|
||||
errMsg: String = '';
|
||||
begin
|
||||
try
|
||||
ZConnection1.Database := AppendPathDelim(Application.Location) + DBFILENAME;
|
||||
ZConnection1.Protocol := 'sqlite'; //-3';
|
||||
ZConnection1.Database := Application.Location + DBFILENAME;
|
||||
{$IFDEF sqlite3}
|
||||
ZConnection1.Protocol := 'sqlite';
|
||||
{$ENDIF}
|
||||
{$IFDEF firebird3}
|
||||
ZConnection1.Protocol := 'firebird';
|
||||
ZConnection1.User := 'SYSDBA';
|
||||
ZConnection1.Password := 'masterkey';
|
||||
ZConnection1.HostName := '';
|
||||
ZConnection1.TransactIsolationLevel := tiReadCommitted;
|
||||
ZConnection1.Properties.Clear;
|
||||
if not FileExists(ZConnection1.Database) then
|
||||
ZConnection1.Properties.Add(
|
||||
'CreateNewDatabase=CREATE DATABASE ' + QuotedStr(ZConnection1.Database) +
|
||||
' USER ' + QuotedStr('SYSDBA') +
|
||||
' PASSWORD ' + QuotedStr('masterkey') +
|
||||
' PAGE_SIZE 4096 DEFAULT CHARACTER SET UTF8');
|
||||
{$ENDIF}
|
||||
|
||||
// ZConnection1.Connect; // activate this to test issue #33717
|
||||
|
||||
VpZeosDatastore1.Connection := ZConnection1;
|
||||
VpZeosDatastore1.AutoCreate := true;
|
||||
{$IFDEF firebird3}
|
||||
ZConnection1.Properties.Clear;
|
||||
{$ENDIF}
|
||||
VpZeosDatastore1.Connected := true;
|
||||
|
||||
if VpZeosDatastore1.Resources.Count > 0 then
|
||||
@ -94,8 +125,13 @@ begin
|
||||
except
|
||||
on E:Exception do
|
||||
begin
|
||||
MessageDlg(E.Message + LineEnding + 'Or copy sqlite3.dll to the exe folder.',
|
||||
mtError, [mbOK], 0);
|
||||
{$IFDEF sqlite3}
|
||||
errMsg := LineEnding + 'Or copy sqlite3.dll to the exe folder.';
|
||||
{$ENDIF}
|
||||
{$IFDEF firebird3}
|
||||
errMsg := LineEnding + 'Or copy fbclient.dll to the exe folder.';
|
||||
{$ENDIF}
|
||||
MessageDlg(E.Message + errMsg, mtError, [mbOK], 0);
|
||||
Close;
|
||||
end;
|
||||
end;
|
||||
|
Reference in New Issue
Block a user