Registriert seit: 18. Aug 2003
648 Beiträge
|
Re: Dialog für Aufbau des Connection String in eigenem Progr
29. Sep 2004, 09:58
Hi!
Ich habs vor kurzem in ner Anwendung auch gebraucht, das man den ConnectionString zur Laufzeit setzen kann. Hier ist mal die Prozedur:
Delphi-Quellcode:
procedure TfrmLogin.FormCreate(Sender: TObject);
var
ini: TIniFile;
begin
OwnFilesPath:=GetSpecialFolder( Handle, CSIDL_PERSONAL);
if FileExists(OwnFilesPath+' \AMS\database.ini')
then begin
ini:=TIniFile.Create(OwnFilesPath+' \AMS\database.ini');
try
with frmMain do begin
varUserID:=ini.ReadString(' DBSettings', ' UserID', ' ');
varDSN:=ini.ReadString(' DBSettings', ' DSN', ' ');
varDB:=ini.ReadString(' DBSettings', ' DB', ' ');
varServer:=ini.ReadString(' DBSettings', ' Server', ' ');
varPassword:=ini.ReadString(' DBSettings', ' Password', ' ');
varPort:=ini.ReadString(' DBSettings', ' Port', ' ');
MySQLCS:=' Provider=MSDASQL.1;Persist Security Info=False;User ID='+varUserID+' ;Data Source='+varDSN+' ;Extended Properties="DSN='+varDSN+' ;DESC=MySQL ODBC 3.51 Driver DSN;DATABASE='+varDB+' ;SERVER='+varServer+' ;UID='+varUserID+' ;PASSWORD='+varPassword+' ;PORT='+varPort+' ;SOCKET=;OPTION=3;STMT=;"';
ADOConnection1.ConnectionString:=MySQLCS;
ADOConnection1.Connected:=true;
end;
finally
ini.Free;
end;
end;
frmLogin.ShowModal;
CloseAction:=caNone;
end;
Akut-Programming
be cool, be hot ... just be
|
|
Zitat
|