Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 20th, 2012  |  syntax: None  |  size: 0.66 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to compare open connection string with connection string from config file
  2. if(con.ConnectionString == ConfigurationManager.ConnectionStrings["Con1"].ConnectionString);
  3.        
  4. if (DateTime.Now.Subtract(lastDBcheck).TotalSeconds > 10 && con.ConnectionString==ConfigurationManager.ConnectionStrings["Con1"].ConnectionString)
  5.        
  6. var con1 = ConfigurationManager.ConnectionStrings["Con1"];
  7.  
  8. if (con != null && con1 != null && con.ConnectionString == con1.ConnectionString) {
  9.     // Connection strings are the same.
  10. }
  11.        
  12. The .NET Framework Data Provider for SQL Server does not persist or return
  13. the password in a connection string unless you set Persist Security Info to true.