1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| function SQLConfigDataSource (hwndParent : hwnd; fRequest : Longint; lpszDriver : AnsiString; lpszAttributes : AnsiString) : Longint; stdcall; external 'ODBCCP32.DLL' name 'SQLConfigDataSource';
// //
function TForm1.CreeDSN(Driver,NomDSN,Description,FichierBaseDeDonnees:string):integer;
var
strDriver : AnsiString;
strAttributes: AnsiString;
begin
strDriver := Driver;
strAttributes := 'DSN='+NomDSN+ #0;
strAttributes := strAttributes + 'DESCRIPTION='+Description + #0;
strAttributes := strAttributes + 'DBQ='+FichierBaseDeDonnees + #0;
{Pour visualiser la boite de dialogue, utiliser Form1.Handle au lieu
de vbAPINull.}
Result :=SQLConfigDataSource(vbAPINull , ODBC_ADD_SYS_DSN, strDriver, strAttributes);
end; |
Partager