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
This commit is contained in:
wp_xxyyzz
2016-07-25 20:48:56 +00:00
parent 47781a3c53
commit ad7008273e
2 changed files with 13 additions and 8 deletions

View File

@ -260,7 +260,7 @@ object Form1: TForm1
Top = 39 Top = 39
Width = 960 Width = 960
OnChange = TabControl1Change OnChange = TabControl1Change
TabIndex = 2 TabIndex = 0
Tabs.Strings = ( Tabs.Strings = (
'Resources' 'Resources'
'Contacts' 'Contacts'
@ -1111,7 +1111,7 @@ object Form1: TForm1
top = 621 top = 621
end end
object ODBCConnection1: TODBCConnection object ODBCConnection1: TODBCConnection
Connected = True Connected = False
LoginPrompt = False LoginPrompt = False
KeepConnection = True KeepConnection = True
Params.Strings = ( Params.Strings = (
@ -1124,7 +1124,7 @@ object Form1: TForm1
top = 304 top = 304
end end
object SQLTransaction1: TSQLTransaction object SQLTransaction1: TSQLTransaction
Active = True Active = False
Database = ODBCConnection1 Database = ODBCConnection1
Options = [] Options = []
left = 136 left = 136

View File

@ -7,7 +7,7 @@ interface
uses uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
StdCtrls, ComCtrls, DBGrids, DbCtrls, VpBaseDS, VpDayView, VpWeekView, StdCtrls, ComCtrls, DBGrids, DbCtrls, VpBaseDS, VpDayView, VpWeekView,
VpTaskList, VpContactGrid, VpMonthView, VpResEditDlg, VpContactButtons, dbf, VpTaskList, VpContactGrid, VpMonthView, VpResEditDlg, VpContactButtons,
db, sqldb, odbcconn, VpData, VpFlxDS; db, sqldb, odbcconn, VpData, VpFlxDS;
type type
@ -82,10 +82,8 @@ implementation
{$R *.lfm} {$R *.lfm}
uses uses
dbf_Common, LazFileUtils; LazFileUtils;
const
DB_DIR = 'data';
{ TForm1 } { TForm1 }
@ -111,6 +109,13 @@ end;
// in the resource combo. // in the resource combo.
procedure TForm1.FormCreate(Sender: TObject); procedure TForm1.FormCreate(Sender: TObject);
begin 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 try
// Connection // Connection
ODBCConnection1.Driver := 'Microsoft Access Driver (*.mdb, *.accdb)'; ODBCConnection1.Driver := 'Microsoft Access Driver (*.mdb, *.accdb)';
@ -141,7 +146,7 @@ begin
except except
on E:Exception do on E:Exception do
begin begin
MessageDlg('ERROR', mtError, [mbOK], 0); MessageDlg(E.Message, mtError, [mbOK], 0);
Close; Close;
end; end;
end; end;