ADO.NET SQL connection string to store connection string
Posted on 2011-09-19
Should be an easy one, I need some VB.net code to get the connection string from a web.config file.
In my web.config file I have a stored connection string
<add name="MyConnectionString" connectionString="Data Source=MyServer;Initial Catalog=MyDb;Integrated Security=True"
I have a vb.net page that I want to create a SQL server connection using the connection string above.
so far I have
Using connection As New SqlConnection("ConnectionStrings:MyConnectionString"")
the syntax above is not working, I cant remember for the life of me how to do this!