Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Datenbanken (https://www.delphipraxis.net/15-datenbanken/)
-   -   Prism Connectionstring per Dialog ermitteln (https://www.delphipraxis.net/32687-connectionstring-per-dialog-ermitteln.html)

nieurig 27. Okt 2004 10:43


Connectionstring per Dialog ermitteln
 
Hallo Leute,
in Programmen für Win32 habe ich beim ersten Programmstart den Benutzer den Connectionsstring mit folgendem Con erstellen lassen:

Code:
newConnString = PromptDataSource(handle,'');
Der Dialog erlaubt die Erstellung des ConnectionString genauso wie in der IDE. Nach der Anzeige der Provider folgt die Festlegung der Userkennung usw.

Ich möchte nun das Gleiche unter Nutzung des .NET Frameworks tun (so dass die Vorgehensweise auch in C# möglich wäre). Weiß jemand wie das geht?

Schon im Voraus vielen Dank für Eure Hinweise.
Niels

Specialwork 19. Nov 2004 22:38

Re: Connectionstring per Dialog ermitteln
 
Hallo Neugierig,

Folgende Methode lößt das Problem in C#:

Delphi-Quellcode:
using System.Data;
using System.Data.OleDb;
using MSDASC;
using ADODB;
Code:
private string DataSourcePrompt(string connectionString)
{
   try
   {
      Connection connection1   = null;
      DataLinks dataLinks1   = new DataLinksClass();

      if (connectionString == string.Empty)
      {
         connection1 = (Connection) dataLinks1.PromptNew();
         return connection1.ConnectionString.ToString();
      }

      connection1                  = new ConnectionClass();
      connection1.ConnectionString   = connectionString;
      object object1               = connection1;
      
      if (dataLinks1.PromptEdit(ref object1))
      {
         connectionString = connection1.ConnectionString;
      }

      connectionString = connectionString;
   }
   catch (Exception exception1)
   {
      Debug.WriteLine(exception1.ToString());
      connectionString = string.Empty;
   }

   return connectionString;
}
Gruß, Tom

[edit=fkerber][delphi]-Tags --> [c]-Tags. Mfg, fkerber[/edit]


Alle Zeitangaben in WEZ +1. Es ist jetzt 08:37 Uhr.

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