Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Connection string in web.config
Message
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
00823105
Message ID:
00823385
Vues:
21
>It is a better idea to put it in the web.config file, which is what we do in MM .NET. However, we wait until instantiating the data access object to retrieve the connection string from web.config. The reason for this, is that developers can store multiple connection strings in their config file which would be different for different types of data.
>
>Here's some details:
>
>1. Connection information is stored in the web.config file for Web apps and the app.config file for Windows Forms apps. A "databaes key" is stored along with the connection information to identify the database to which the connection belongs. One entry is created for each database accessed from the application.
>
>2. At run time, the data access object is instantiated when the first request for data is made (JIT instantiation)
>
>2. When the data access object instantiates, a call is made to the Database Manager's GetConnectionString method, passing the database "key" (a string used to identify a particular database).
>
>3. If a connection for this database key hasn't been requested before, the Database Manager reads the config file to retrieve it, then caches this information in its connection collection for subsequent requests
>
>Hope this helps!

Thank you. Yes, it does help. I think I understand what you are saying about the Database Manager. I am assuming the Database Manager is an object instantied by the Application object, similar to what was done in VFP Mere Mortals? If so, how does this work in a web application? I haven't thought of this before, but in a web application can you instantiate an object such as a Database Manager and have it persist through the lifetime of the app? If so, I guess you would do this in Global.Application_Start()?
Chris McCandless
Red Sky Software
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform