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
This commit is contained in:
wp_xxyyzz
2016-09-17 17:10:43 +00:00
parent 824cbb6a59
commit ecdb5f28de
5 changed files with 19 additions and 16 deletions

View File

@ -60,6 +60,14 @@
<IncludeFiles Value="$(ProjOutDir)"/> <IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths> </SearchPaths>
<CodeGeneration>
<Checks>
<IOChecks Value="True"/>
<RangeChecks Value="True"/>
<OverflowChecks Value="True"/>
<StackChecks Value="True"/>
</Checks>
</CodeGeneration>
<Linking> <Linking>
<Options> <Options>
<Win32> <Win32>

View File

@ -6,6 +6,7 @@ Login parameters for the created database:
password: masterkey password: masterkey
NOTE: NOTE:
The project creates a new database on the fly. For reasons unknown at the moment, The project creates a new database on the fly using above-menitoned login
an exception is raised here if started from the IDE. This does not happen any parameters. For reasons unknown at the moment, the first program entries after
more once the database exists. adding a resource are not stored --> a restart of the demo program is required
after adding the first resource.

View File

@ -278,7 +278,7 @@ object Form1: TForm1
end end
object SQLTransaction1: TSQLTransaction object SQLTransaction1: TSQLTransaction
Active = False Active = False
Action = caCommit Action = caCommitRetaining
Database = IBConnection1 Database = IBConnection1
Options = [] Options = []
left = 256 left = 256
@ -321,6 +321,7 @@ object Form1: TForm1
LoginPrompt = False LoginPrompt = False
KeepConnection = True KeepConnection = True
Transaction = SQLTransaction1 Transaction = SQLTransaction1
HostName = 'localhost'
Options = [] Options = []
left = 136 left = 136
top = 120 top = 120

View File

@ -89,8 +89,6 @@ begin
VpFirebirdDatastore1.Connection := IBConnection1; VpFirebirdDatastore1.Connection := IBConnection1;
VpFirebirdDatastore1.AutoCreate := true; VpFirebirdDatastore1.AutoCreate := true;
VpFirebirdDatastore1.CreateTables;
VpFirebirdDatastore1.Connected := true; VpFirebirdDatastore1.Connected := true;

View File

@ -100,15 +100,13 @@ end;
procedure TVpFirebirdDatastore.CreateAllTables(dbIsNew: Boolean); procedure TVpFirebirdDatastore.CreateAllTables(dbIsNew: Boolean);
var var
tableNames: TStringList; tableNames: TStringList;
needCommit: Boolean;
begin begin
needCommit := false;
if dbIsNew then begin if dbIsNew then begin
CreateTable(ContactsTableName); CreateTable(ContactsTableName);
CreateTable(EventsTableName); CreateTable(EventsTableName);
CreateTable(ResourceTableName); CreateTable(ResourceTableName);
CreateTable(TasksTableName); CreateTable(TasksTableName);
needCommit := true; FConnection.Transaction.Commit;
end else end else
begin begin
tablenames := TStringList.Create; tablenames := TStringList.Create;
@ -118,30 +116,27 @@ begin
if tablenames.IndexOf(ContactsTableName) = -1 then begin if tablenames.IndexOf(ContactsTableName) = -1 then begin
CreateTable(ContactsTableName); CreateTable(ContactsTableName);
needCommit := true; FConnection.Transaction.Commit;
end; end;
if tablenames.IndexOf(EventsTableName) = -1 then begin if tablenames.IndexOf(EventsTableName) = -1 then begin
CreateTable(EventsTableName); CreateTable(EventsTableName);
needCommit := true; FConnection.Transaction.Commit;
end; end;
if tablenames.IndexOf(ResourceTableName) = -1 then begin if tablenames.IndexOf(ResourceTableName) = -1 then begin
CreateTable(ResourceTableName); CreateTable(ResourceTableName);
needCommit := true; FConnection.Transaction.Commit;
end; end;
if tablenames.IndexOf(TasksTableName) = -1 then begin if tablenames.IndexOf(TasksTableName) = -1 then begin
CreateTable(TasksTableName); CreateTable(TasksTableName);
needCommit := true; FConnection.Transaction.Commit;
end; end;
finally finally
tablenames.Free; tablenames.Free;
end; end;
end; end;
if needCommit then
FConnection.Transaction.Commit;
end; end;
// Connection and tables are active afterwards! // Connection and tables are active afterwards!