code_junkie

Dynamically assigning projects property name to variable within a class

Nov 12th, 2011
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. public class connClass
  2.  
  3. {
  4.  
  5. NpgsqlConnection conn = new NpgsqlConnection(projectName.Properties.Settings.Default.ConnString);
  6.  
  7. }
  8.  
  9. String connStr = ConfigurationManager.ConnectionStrings["DefaultConnStr"].ConnectionString;
  10.  
  11. <configuration>
  12. <connectionStrings>
  13. <add name="DefaultConnStr" connectionString="Data Source=127.0.0.1..."/>
  14. </connectionStrings>
  15. </configuration>
  16.  
  17. ConfigurationManager.AppSettings["PROJECT_NAME"];
Add Comment
Please, Sign In to add comment