Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Library: Datenbanken (https://www.delphipraxis.net/22-library-datenbanken/)
-   -   Delphi ADO Connection in eine UDL-Datei speichern (https://www.delphipraxis.net/30778-ado-connection-eine-udl-datei-speichern.html)

shmia 29. Sep 2004 09:36


ADO Connection in eine UDL-Datei speichern
 
Mit folgender Procedure kann man einen ADO Connection String in eine UDL-Datei speichern.
Man sollte darauf achten, dass der Connection String nicht schon seinerseits auf eine UDL-Datei verweist.
Delphi-Quellcode:
{**************************************************************************
 * NAME:   SaveConnectionToUDLFile
 * DESC:   stores a connection string into a UDL file
 *************************************************************************}
procedure SaveConnectionToUDLFile(const connstr:string; const filename:string);
  procedure SaveWideStringToFile(const ws:WideString; const filename:string);
  var
    fs : TFileStream;
  begin
    fs := TFileStream.Create(filename, fmCreate);
    try
      fs.WriteBuffer(ws[1], Length(ws)*sizeof(Widechar));
    finally
      fs.Free;
    end;
  end;
var
  ws : WideString;
begin
  ws := ' [oledb]'#13#10+
    '; Everything after this line is an OLE DB initstring'#13#10+
    Trim(connstr);
  s[1] := Widechar($FEFF);

  SaveWideStringToFile(ws, filename);
end;
[edit=Matze]Code formatiert. Mfg, Matze[/edit]


Alle Zeitangaben in WEZ +1. Es ist jetzt 19:03 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz