From ad7008273ecbce9807da239d76115d8acc8005ce Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Mon, 25 Jul 2016 20:48:56 +0000 Subject: [PATCH] tvplanit: FlexDatastore demo for Access: remove unused units, add error message if mdb file is not found. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5032 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../examples/datastores/flex/access/unit1.lfm | 6 +++--- .../examples/datastores/flex/access/unit1.pas | 15 ++++++++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/components/tvplanit/examples/datastores/flex/access/unit1.lfm b/components/tvplanit/examples/datastores/flex/access/unit1.lfm index 169b6933e..753ef3369 100644 --- a/components/tvplanit/examples/datastores/flex/access/unit1.lfm +++ b/components/tvplanit/examples/datastores/flex/access/unit1.lfm @@ -260,7 +260,7 @@ object Form1: TForm1 Top = 39 Width = 960 OnChange = TabControl1Change - TabIndex = 2 + TabIndex = 0 Tabs.Strings = ( 'Resources' 'Contacts' @@ -1111,7 +1111,7 @@ object Form1: TForm1 top = 621 end object ODBCConnection1: TODBCConnection - Connected = True + Connected = False LoginPrompt = False KeepConnection = True Params.Strings = ( @@ -1124,7 +1124,7 @@ object Form1: TForm1 top = 304 end object SQLTransaction1: TSQLTransaction - Active = True + Active = False Database = ODBCConnection1 Options = [] left = 136 diff --git a/components/tvplanit/examples/datastores/flex/access/unit1.pas b/components/tvplanit/examples/datastores/flex/access/unit1.pas index a24c89ad8..5dee5fca2 100644 --- a/components/tvplanit/examples/datastores/flex/access/unit1.pas +++ b/components/tvplanit/examples/datastores/flex/access/unit1.pas @@ -7,7 +7,7 @@ interface uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls, ComCtrls, DBGrids, DbCtrls, VpBaseDS, VpDayView, VpWeekView, - VpTaskList, VpContactGrid, VpMonthView, VpResEditDlg, VpContactButtons, dbf, + VpTaskList, VpContactGrid, VpMonthView, VpResEditDlg, VpContactButtons, db, sqldb, odbcconn, VpData, VpFlxDS; type @@ -82,10 +82,8 @@ implementation {$R *.lfm} uses - dbf_Common, LazFileUtils; + LazFileUtils; -const - DB_DIR = 'data'; { TForm1 } @@ -111,6 +109,13 @@ end; // in the resource combo. procedure TForm1.FormCreate(Sender: TObject); begin + if not FileExists('data.mdb') then begin + MessageDlg('Database file "data.mdb" does not exist. ' + LineEnding + + 'Please run "CreateAccessDB" to create an empty Access database file.', + mtError, [mbOK], 0); + Close;exit; + end; + try // Connection ODBCConnection1.Driver := 'Microsoft Access Driver (*.mdb, *.accdb)'; @@ -141,7 +146,7 @@ begin except on E:Exception do begin - MessageDlg('ERROR', mtError, [mbOK], 0); + MessageDlg(E.Message, mtError, [mbOK], 0); Close; end; end;