{"id":2340,"date":"2012-11-07T11:34:22","date_gmt":"2012-11-07T15:34:22","guid":{"rendered":"http:\/\/www.iowawebnet.com\/ein\/?p=2340"},"modified":"2012-11-07T11:34:22","modified_gmt":"2012-11-07T15:34:22","slug":"oledbconnection-string-with-configurationmanager","status":"publish","type":"post","link":"https:\/\/www.iowawebnet.com\/ein\/2012\/11\/oledbconnection-string-with-configurationmanager\/","title":{"rendered":"OleDbConnection string with ConfigurationManager"},"content":{"rendered":"<pre>\r\nWeb config\r\n<code>\r\n&#60;add \r\n   name=\"MyConnectionString\" \r\n   connectionString=\"Data Source=SRV-MY-SQL\\SQLCLSTR12;\r\n   Initial Catalog=MyDatabaseName;\r\n   Persist Security Info=True;User ID=MyUser;Password=MyPassword\"\r\n   providerName=\"System.Data.SqlClient\" \/>\r\n<\/code>\r\nCode behind or markup page\r\n<code>\r\n'defines sql connection\r\nDim connString As String\r\nconnString = ConfigurationManager.ConnectionStrings(\"MyConnectionString\").ToString\r\nDim ConnDB As New OleDbConnection(\"Provider=sqloledb;\" & connString)\r\n'define oledbcommand\r\nDim cmd As New OleDbCommand(\"SELECT * _\r\n                            \"FROM my_table _\r\n                            \"WHERE name='Mike' ;\", ConnDB)\r\nDim reader As OleDbDataReader\r\n<\/code>\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Web config &#60;add name=&#8221;MyConnectionString&#8221; connectionString=&#8221;Data Source=SRV-MY-SQL\\SQLCLSTR12; Initial Catalog=MyDatabaseName; Persist Security Info=True;User ID=MyUser;Password=MyPassword&#8221; providerName=&#8221;System.Data.SqlClient&#8221; \/> Code behind or markup page &#8216;defines sql connection Dim connString As String connString = ConfigurationManager.ConnectionStrings(&#8220;MyConnectionString&#8221;).ToString Dim ConnDB As New OleDbConnection(&#8220;Provider=sqloledb;&#8221; &#038; connString) &#8216;define oledbcommand Dim cmd As New OleDbCommand(&#8220;SELECT * _ &#8220;FROM my_table _ &#8220;WHERE name=&#8217;Mike&#8217; ;&#8221;, ConnDB) Dim reader As [&hellip;]<\/p>\n","protected":false},"author":35,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[85,17,16,32],"tags":[19,121,146,21],"class_list":["post-2340","post","type-post","status-publish","format-standard","hentry","category-net-4-0","category-applications","category-net","category-ms-sql","tag-asp-net","tag-oledbconnection","tag-sql","tag-visual-studio"],"_links":{"self":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts\/2340"}],"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=2340"}],"version-history":[{"count":11,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts\/2340\/revisions"}],"predecessor-version":[{"id":2351,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts\/2340\/revisions\/2351"}],"wp:attachment":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/media?parent=2340"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/categories?post=2340"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/tags?post=2340"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}