Skip to content

Commit af41915

Browse files
committed
New method to locate the demo SQL database FDDEMO.SDB, otherwise database demos cannot be executed without this sample file
1 parent 335d17a commit af41915

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

demos/FireMonkey/TeeGridFeatures/Views/Database/Master_Detail_FireDAC/Customer_Orders.dfm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ object SampleData: TSampleData
33
Width = 267
44
object Sqlite_demoConnection: TFDConnection
55
Params.Strings = (
6-
'Database=D:\apps\Embarcadero\Studio\19.0\Samples\Data\FDDemo.sdb'
6+
'Database=FDDemo.sdb'
77
'ConnectionDef=SQLite_Demo')
88
LoginPrompt = False
99
Left = 103

demos/FireMonkey/TeeGridFeatures/Views/Database/Master_Detail_FireDAC/Customer_Orders.pas

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ TSampleData = class(TDataModule)
2424
public
2525
{ Public declarations }
2626

27+
procedure OpenTables;
2728
function OrdersOfCustomer(const ARecNo:Integer):TDataSet;
2829
end;
2930

@@ -36,6 +37,36 @@ implementation
3637

3738
{$R *.dfm}
3839

40+
uses
41+
IOUtils;
42+
43+
function FolderWithSampleData:String;
44+
begin
45+
result:='fddemo.sdb';
46+
47+
repeat
48+
if TFile.Exists(result) then
49+
exit
50+
else
51+
result:=TPath.Combine('..',result);
52+
53+
until Length(result)>100;
54+
end;
55+
56+
procedure TSampleData.OpenTables;
57+
var Path : String;
58+
begin
59+
Path:=FolderWithSampleData;
60+
61+
if Path='' then
62+
raise Exception.Create('Error: Missing SQL sample database file FDDEMO.SDB required by this demo');
63+
64+
Sqlite_demoConnection.Params.Values['Database']:=Path;
65+
66+
CustomersTable.Open;
67+
OrdersTable.Open;
68+
end;
69+
3970
function TSampleData.OrdersOfCustomer(const ARecNo:Integer):TDataSet;
4071

4172
// Return the CustomerID for row: ARow

0 commit comments

Comments
 (0)