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
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

View File

@ -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;