Einzelnen Beitrag anzeigen

Elvis

Registriert seit: 25. Nov 2005
Ort: München
1.909 Beiträge
 
Delphi 2010 Professional
 
#6

Re: ConnectionString aus Web.Config auslesen

  Alt 26. Apr 2007, 10:55
Warum nicht einfach so?
Code:
ConnectionStringSettings connectionSettings = WebConfigurationManager.ConnectionStrings["Mööp"];
if(connectionsettings != null)
{
  DbProviderFactory factory = DbProviderFactories.GetFactory(connectionSettings.ProviderName);
  using(DbConnection connection = factory.CreateConnection())
  using(DbCommand command = connection.CreateCommand())
  {
    connection.ConnectionString = connectionSettings.ConnectionString;
    ...
  }
}
Robert Giesecke
I’m a great believer in “Occam’s Razor,” the principle which says:
“If you say something complicated, I’ll slit your throat.”
  Mit Zitat antworten Zitat