C#•Add Flexibility Using App.config

Listing 4. Data access applications require you to specify the server, database, and table in the code. EMAB, however, enables you to override these values at run time by setting attributes in app.config.

if (cfgSettings != null)
{
   if (cfgSettings["serverName"] != null &&  
   cfgSettings["serverName"].Length > 0)
   {  
      serverName = cfgSettings["serverName"];
   }
   if (cfgSettings["databaseName"] !=null && 
   cfgSettings["databaseName"].Length > 0)
   {
      databaseName = cfgSettings["databaseName"];
   }
   if (cfgSettings["tableName"] !=null && 
   cfgSettings["tableName"].Length > 0)
   {
      tableName = cfgSettings["tableName"];
   }
}