[cc lang=”delphi” tab_size=”2″ line_numbers=”false” no_links=”false”]
// uses comobj;
function CreateDatabase(DatabaseName: string): boolean;
var
DBEngine, Workspace: Variant;
const
dbLangGeneral = ‘;LANGID=0x0409;CP=1252;COUNTRY=0’;
dbVersion30 = 32;
begin
result := false;
try
try
DBEngine := CreateOleObject(‘DAO.DBEngine.36’);
except
try {For DAO 3.5}
DBEngine := CreateOleObject(‘DAO.DBEngine.35’);
except
raise;
end;
end;
Workspace := DBEngine.Workspaces[0];
try
Workspace.CreateDatabase(DatabaseName, dbLangGeneral, dbVersion30);
except on e0: EOleException do
ShowMessage(e0.Message);
end;
except on e1: EOleException do
ShowMessage(e1.Message);
end;
result := true;
end;
/////////////////////////////////////////////////
CreateDatabase(‘Имя базы данных’); // Команда создания БД.
[/cc]