zeko
asked on
Access database
How can I create Access database with
two tables ???
two tables ???
from Delphi or within Access?
ASKER
FROM Delphi 5.0
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
Your welcome
Kevin
Kevin
ASKER
How can I put password on this database ?
Easy, the example below is modified from the prior code.
{ Creates an empty MS-Access database with a password. Note that the password
is done in the second parameter to CreateDatabase. Also when opening the
database via automation you must pass in the password as shown here. Opening
the database via MS-Access invokes a "Login" dialog. }
function TForm1.CreateMDB(cDatabase Name: String): boolean ;
const
MyPassWord = 'Kevin' ;
dbLangGeneral = ';LANGID=0x0409;CP=1252;CO UNTRY=0;PW D=' + MyPassWord ;
dbVersion = 32 ;
begin
if FileExists(cDatabaseName + '.mdb') then
if not DeleteFile(cDatabaseName + '.mdb') then
begin
ErrorMsg('Failed to remove' + #13 + cDatabaseName + '.mdb') ;
Result := False ;
exit ;
end ;
Workspace := DBEngine.Workspaces[0] ;
try
{ Create the MDB }
Workspace.CreateDatabase(c DatabaseNa me,dbLangG eneral, dbVersion) ;
dbs := dbEngine.OpenDatabase(cDat abaseName, False,Fals e,'MS Access;PWD=' + MyPassWord) ;
Result := True ;
except
ErrorMsg('Failed to create' + #13 + cDatabaseName + '.mdb') ;
Result := False ;
exit ;
end ;
end ;
Kevin
{ Creates an empty MS-Access database with a password. Note that the password
is done in the second parameter to CreateDatabase. Also when opening the
database via automation you must pass in the password as shown here. Opening
the database via MS-Access invokes a "Login" dialog. }
function TForm1.CreateMDB(cDatabase
const
MyPassWord = 'Kevin' ;
dbLangGeneral = ';LANGID=0x0409;CP=1252;CO
dbVersion = 32 ;
begin
if FileExists(cDatabaseName + '.mdb') then
if not DeleteFile(cDatabaseName + '.mdb') then
begin
ErrorMsg('Failed to remove' + #13 + cDatabaseName + '.mdb') ;
Result := False ;
exit ;
end ;
Workspace := DBEngine.Workspaces[0] ;
try
{ Create the MDB }
Workspace.CreateDatabase(c
dbs := dbEngine.OpenDatabase(cDat
Result := True ;
except
ErrorMsg('Failed to create' + #13 + cDatabaseName + '.mdb') ;
Result := False ;
exit ;
end ;
end ;
Kevin