Specifying Database Sets in the Config File
At times you may need your application to access different sets of data. For example, you may want end users to switch between test data, staging data, and production data. You may also have a situation where you have different databases for different customers. This is where database sets come to the rescue.
A database set can consist of one or more databases. End users can switch between these database sets at runtime by means of the application Options dialog (accessed from the File | Options menu). You can also change the current database set programmatically at run time. For more information, see the Help topic The DataBase Manager for details.
Note: For an example of database sets, see the MM .NET Northwind Sample application.
To set up database sets in the application configuration file:
- If it's not already there, add the following element to the application configuration file within the <configSections> element:
<configSections> <section name="databaseSets" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
- Add a new <DatabaseSetDefault> element within the <appSettings> element. For example:
<appSettings> <add key="DatabaseSetDefault" value="CustA" />
This setting is used to specify the current default data set when your application first starts up.
- Add a new <databaseSets> element below the <appSettings> element. Add an entry for each database set. For example:
<databaseSets> <add key="CustA" value="Customer A (SQL Server)" /> <add key="CustB" value="Customer B (Visual FoxPro)" /> </databaseSets>
- Add the database set key value prefix (i.e. "CustA\", "CustB\" to the corresponding elements within the <databases> element. For example:
<databases> <add key="CustA\Northwind\Connection" value="Data Source=(local);Initial Catalog=Northwind;Integrated Security=True" /> <add key="CustA\Northwind\DataAccessClass" value="DataAccessSql" /> <add key="CustB\Northwind\Connection" value="Provider=vfpoledb.1;Data Source=C:\Temp\VFPData\northwind.dbc" /> <add key="CustB\Northwind\DataAccessClass" value="DataAccessVFP" /> </databases>
© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 07/18/18
Comment or report problem with topic
