|
|
C#
protected void Page_Load(object sender, EventArgs e)
{string connStr = WebConfigurationManager.ConnectionStrings
["NorthwindConnectionString"].ConnectionString;SqlConnectionStringBuilder bldr = new SqlConnectionStringBuilder(connStr);
// displays (local)string dataSrc = bldr.DataSource;// displays Northwindstring iniCat = bldr.InitialCatalog;}
VB.NET
Protected Sub Page_Load(ByVal sender As Object, _
ByVal e As EventArgs)
Dim connStr As String = _
WebConfigurationManager.ConnectionStrings _
("NorthwindConnectionString").ConnectionStringDim bldr As New SqlConnectionStringBuilder(connStr)
' displays (local)Dim dataSrc As String = bldr.DataSource
' displays NorthwindDim iniCat As String = bldr.InitialCatalog
End Sub
As shown above, we use the SqlConnectionStringBuilder to extract the contents of a connection string. This class provides a simple way to create and manage contents of the ConnectionString.
'Like' us on our FaceBook page if you find this blog useful. Thanks!
Did you like this post?
|
|
|
||
|
|
|
|
Save on Delicious |
|
|
subscribe via rss |
|
subscribe via e-mail |
|
|
print this post |
|
follow me on twitter |




comments
0 Responses to "Extract Individual Contents of the Connection String from your Web.Config"Post a Comment