Thursday, 27 June 2013

Build SqlConnection StringBuilder from connection string

Build SqlConnectionStringBuilder from connection string

Provides a simple way to create and manage the contents of connection strings used by the SqlConnection class.
Property:
  1. ApplicationName
  2. AsynchronousProcessing
  3. AttachDBFilename
  4. BrowsableConnectionString
  5. ConnectionReset
  6. ConnectionString
  7. ConnectTimeout
  8. ContextConnection
  9. CurrentLanguage
  10. DataSource
  11. FailoverPartner
  12. InitialCatalog
  13. IntegratedSecurity
  14. IsFixedSize
  15. IsReadOnly
  16. LoadBalanceTimeout
  17. MaxPoolSize
  18. MinPoolSize
  19. MultipleActiveResultSets
  20. NetworkLibrary
  21. PacketSize
  22. PersistSecurityInfo
  23. TransactionBinding
  24. System.Transactions
  25. TrustServerCertificate
  26. TypeSystemVersion
  27. UserID
  28. UserInstance
  29. WorkstationID
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
    string conString=@"Data Source=R4R-3EFD13BB468\SQLEXPRESS; 
    initial catalog=newDatabase;integrated security=true;
    Min Pool Size=5;Max Pool Size=15;Connection Reset=True; Connection Lifetime=600;";
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnectionStringBuilder sub = new SqlConnectionStringBuilder(conString);
        Response.Write("Parsed SQL Connection String Parameters:");
        Response.Write("  Database Source = " + sub.DataSource);
        Response.Write("  Database = " + sub.InitialCatalog);
        Response.Write("  Use Integrated Security = " + sub.IntegratedSecurity);
        Response.Write("  Min Pool Size = " + sub.MinPoolSize);
        Response.Write("  Max Pool Size = " + sub.MaxPoolSize);
        Response.Write("  Lifetime = " + sub.LoadBalanceTimeout);
        Response.Write("  Connection Reset = " + sub.ConnectionReset);
    }  
}

No comments: