Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Dynamically setting connection string
Message
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
Dynamically setting connection string
Divers
Thread ID:
00936360
Message ID:
00936360
Vues:
69
Kevin,
Due to our security requirements, we only wish to hard-code a single connection string to a central database "traffic cop" that has access to a single login procedure. The user's login determines which set or sets of databases they can use, which client's data they can view, their role and any custom security access or denials afforded them. Databases for the application come in sets, each database for a different purpose, possibly on different servers. Some database sets are single-tenant, others multi-tenant. The login process returns them the set of connection strings for the database set they will use for the client data they will be working on.

We do not want to have to have entries in app.config or web.config for all of our databases on all of our servers. We need the flexibility to change the data source, user ID, password and initial catalog on the connection strings.

Currently, I am trying to see if I can set the connection string programmatically. I tried the following to no avail:

web.config:
  <databaseSets>
    <add key="TrafficCop" value="TrafficCop" />
    <add key="Generic" value="Generic" />
  </databaseSets>
  
  <databases>
    <add key="P1SQL\TrafficCop\Connection" value="server=P1SQL;uid=LgnOnly;pwd=ScurPswd;database=TrafficCop;" />
    <add key="P1SQL\TrafficCop\DataAccessClass" value="DataAccessSql" />
    
    <add key="Generic\Northwind\Connection" value="" />
    <add key="Generic\Northwind\DataAccessClass" value="DataAccessSql" />
    
  </databases>
In Page_Load event on page:
mmAppBase.DatabaseMgr.DatabaseSetKey = "Generic";
mmAppWeb.UserMgr.SetDataAccessObject("Generic","Northwind","Data Source=D1SQL;User ID=TheUsername;Password=ThePassword;Initial Catalog=NorthWind","DataAccessSql");
Despite setting a value with SetDataAccessObject(), it still reads the config file and thinks I have no connection string.

Suggestions?

Thanks!
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform