function TEDBConnect.CreateDBConnection(AEDBTyp: TEDBTyp; DataSource:
string; InitDB:
string; UN:
String; PW:
String; ShowMsg: boolean=false; AccessDBPW:
String = '
'; WindowsSecurity: boolean=false): boolean;
var
asTimeout, asDataSource, asUN, asPW, asInitDB, ConnectionString: AnsiString;
iReturn: Integer;
OldCursor: TCursor;
begin
result := false;
asInitDB := '
';
asUN := '
';
asPW := '
';
LastErrorToZero;
....
ConnectionString := '
DRIVER={SQL Server}';
asDataSource := '
;SERVER='+DataSource;
asInitDB := '
;Initial Catalog=''
'+InitDB+'
''
';
if WindowsSecurity
then // <------ Wenn Windows Sicherheit dann Integrated Security=SSPI ansonnsten Persist Security Info=True
ConnectionString := ConnectionString + '
;Integrated Security=SSPI' + '
;Persist Security Info=False'
else begin
ConnectionString := ConnectionString + '
;Persist Security Info=True';
asUN := UN;
asPW := PW;
end;
// ------>>
end;
....
ConnectionString := ConnectionString + asDataSource;
if trim(asInitDB) <> '
'
then
ConnectionString := ConnectionString + asInitDB;
if trim(asUN) <> '
'
then
ConnectionString := ConnectionString + '
;User ID=' + asUN;
if trim(asPW) <> '
'
then
ConnectionString := ConnectionString + '
;Password=' + asPW;
if trim(AccessDBPW) <> '
'
then
ConnectionString := ConnectionString + '
;Jet OLEDB:Database Password='+AccessDBPW;
// Showmessage(ConnectionString);
// öffne Eine verbindung mit dem ConnectionString
if OpenConnection(ConnectionString, ShowMsg, asUN, asPW)
then begin
result := true;
end;
end;