{"id":2102,"date":"2012-08-21T16:32:39","date_gmt":"2012-08-21T20:32:39","guid":{"rendered":"http:\/\/www.iowawebnet.com\/ein\/?p=2102"},"modified":"2012-08-21T16:56:19","modified_gmt":"2012-08-21T20:56:19","slug":"oledbconnection-from-web-config-file-in-code-behind","status":"publish","type":"post","link":"https:\/\/www.iowawebnet.com\/ein\/2012\/08\/oledbconnection-from-web-config-file-in-code-behind\/","title":{"rendered":"SqlConnection from web config file in code behind"},"content":{"rendered":"<pre>\r\ntest.aspx.vb\r\n<code>\r\nImports System.Data.SqlClient\r\n-------------------------------------\r\nDim connString As String\r\nconnString = ConfigurationManager.ConnectionStrings(\"MyConnectionString1\").ToString\r\nDim conn As New SqlConnection(connString)\r\n<\/code>\r\n<\/pre>\n<pre>\r\nweb.config\r\n<code>\r\n&lt;connectionstrings>\r\n&lt;add name=\"MyConnectionString1\" \r\nconnectionString=\"Data Source=MY-SQL-SRV;Initial Catalog=Northwind;\r\nPersist Security Info=True;\r\nUser ID=my_user;Password=my_pwd\" providerName=\"System.Data.SqlClient\" \/>\r\n &lt;\/connectionstrings>\r\n<\/code>\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>test.aspx.vb Imports System.Data.SqlClient &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- Dim connString As String connString = ConfigurationManager.ConnectionStrings(&#8220;MyConnectionString1&#8243;).ToString Dim conn As New SqlConnection(connString) web.config &lt;connectionstrings> &lt;add name=&#8221;MyConnectionString1&#8243; connectionString=&#8221;Data Source=MY-SQL-SRV;Initial Catalog=Northwind; Persist Security Info=True; User ID=my_user;Password=my_pwd&#8221; providerName=&#8221;System.Data.SqlClient&#8221; \/> &lt;\/connectionstrings><\/p>\n","protected":false},"author":35,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[85,28,17,32,84],"tags":[19,21],"class_list":["post-2102","post","type-post","status-publish","format-standard","hentry","category-net-4-0","category-access","category-applications","category-ms-sql","category-vs2010","tag-asp-net","tag-visual-studio"],"_links":{"self":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts\/2102"}],"collection":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/comments?post=2102"}],"version-history":[{"count":12,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts\/2102\/revisions"}],"predecessor-version":[{"id":2112,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts\/2102\/revisions\/2112"}],"wp:attachment":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/media?parent=2102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/categories?post=2102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/tags?post=2102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}