From ecdb5f28de3e85edcfa1b99573a65676a9c344a2 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sat, 17 Sep 2016 17:10:43 +0000 Subject: [PATCH] tvplaint: Fix FireBird datastore demo crashing after creating the DB. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5172 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../tvplanit/examples/datastores/fb/project1.lpi | 8 ++++++++ .../tvplanit/examples/datastores/fb/readme.txt | 7 ++++--- .../tvplanit/examples/datastores/fb/unit1.lfm | 3 ++- .../tvplanit/examples/datastores/fb/unit1.pas | 2 -- components/tvplanit/source/vpfbds.pas | 15 +++++---------- 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/components/tvplanit/examples/datastores/fb/project1.lpi b/components/tvplanit/examples/datastores/fb/project1.lpi index 2d81d24bd..706ca6d2d 100644 --- a/components/tvplanit/examples/datastores/fb/project1.lpi +++ b/components/tvplanit/examples/datastores/fb/project1.lpi @@ -60,6 +60,14 @@ + + + + + + + + diff --git a/components/tvplanit/examples/datastores/fb/readme.txt b/components/tvplanit/examples/datastores/fb/readme.txt index 211e29787..bea01c179 100644 --- a/components/tvplanit/examples/datastores/fb/readme.txt +++ b/components/tvplanit/examples/datastores/fb/readme.txt @@ -6,6 +6,7 @@ Login parameters for the created database: password: masterkey NOTE: -The project creates a new database on the fly. For reasons unknown at the moment, -an exception is raised here if started from the IDE. This does not happen any -more once the database exists. +The project creates a new database on the fly using above-menitoned login +parameters. For reasons unknown at the moment, the first program entries after +adding a resource are not stored --> a restart of the demo program is required +after adding the first resource. diff --git a/components/tvplanit/examples/datastores/fb/unit1.lfm b/components/tvplanit/examples/datastores/fb/unit1.lfm index 918812ec9..e00ab85fe 100644 --- a/components/tvplanit/examples/datastores/fb/unit1.lfm +++ b/components/tvplanit/examples/datastores/fb/unit1.lfm @@ -278,7 +278,7 @@ object Form1: TForm1 end object SQLTransaction1: TSQLTransaction Active = False - Action = caCommit + Action = caCommitRetaining Database = IBConnection1 Options = [] left = 256 @@ -321,6 +321,7 @@ object Form1: TForm1 LoginPrompt = False KeepConnection = True Transaction = SQLTransaction1 + HostName = 'localhost' Options = [] left = 136 top = 120 diff --git a/components/tvplanit/examples/datastores/fb/unit1.pas b/components/tvplanit/examples/datastores/fb/unit1.pas index 3a119f0fe..a38527bbf 100644 --- a/components/tvplanit/examples/datastores/fb/unit1.pas +++ b/components/tvplanit/examples/datastores/fb/unit1.pas @@ -89,8 +89,6 @@ begin VpFirebirdDatastore1.Connection := IBConnection1; VpFirebirdDatastore1.AutoCreate := true; - VpFirebirdDatastore1.CreateTables; - VpFirebirdDatastore1.Connected := true; diff --git a/components/tvplanit/source/vpfbds.pas b/components/tvplanit/source/vpfbds.pas index a9e1dc572..a3472b93a 100644 --- a/components/tvplanit/source/vpfbds.pas +++ b/components/tvplanit/source/vpfbds.pas @@ -100,15 +100,13 @@ end; procedure TVpFirebirdDatastore.CreateAllTables(dbIsNew: Boolean); var tableNames: TStringList; - needCommit: Boolean; begin - needCommit := false; if dbIsNew then begin CreateTable(ContactsTableName); CreateTable(EventsTableName); CreateTable(ResourceTableName); CreateTable(TasksTableName); - needCommit := true; + FConnection.Transaction.Commit; end else begin tablenames := TStringList.Create; @@ -118,30 +116,27 @@ begin if tablenames.IndexOf(ContactsTableName) = -1 then begin CreateTable(ContactsTableName); - needCommit := true; + FConnection.Transaction.Commit; end; if tablenames.IndexOf(EventsTableName) = -1 then begin CreateTable(EventsTableName); - needCommit := true; + FConnection.Transaction.Commit; end; if tablenames.IndexOf(ResourceTableName) = -1 then begin CreateTable(ResourceTableName); - needCommit := true; + FConnection.Transaction.Commit; end; if tablenames.IndexOf(TasksTableName) = -1 then begin CreateTable(TasksTableName); - needCommit := true; + FConnection.Transaction.Commit; end; finally tablenames.Free; end; end; - - if needCommit then - FConnection.Transaction.Commit; end; // Connection and tables are active afterwards!