procedure TdmMain.DataModuleCreate(Sender: TObject);
var
regReadCon: TRegistry;
sDataBase, sUserName, sPassword: String;
begin
regReadCon := TRegistry.Create;
regReadCon.RootKey := HKEY_LOCAL_MACHINE;
Try
with AdoCnn do
begin
Close;
if Not(regReadCon.OpenKey('SOFTWARE/LIANDA/SF', False)) then
begin
ShowMessage('读取注册表失败!');
Close;
end
else begin
sDataBase := regReadCon.ReadString('DataBase');
sUserName := regReadCon.ReadString('UserName');
sPassword := regReadCon.ReadString('Password');
end;
ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=True;User Id=Admin;';
ConnectionString := ConnectionString + 'Data Source=' + sDataBase + ';';
ConnectionString := ConnectionString + 'Jet OLEDB
ataBase Password=' + sPassword;
Try
Close;
Open;
Except
ShowMessage('连接数据库失败!');
Close;
end;
end;
Finally
regReadCon.Free;
end;
end;
end.