How can I get from VB code the connectionStrings?
I have this in web.config and i need to use it from vb to pass it on a variable:
开发者_开发问答<connectionStrings>
<clear/>
<add name="SQL1" connectionString="..." providerName="System.Data.SqlClient"/>
</connectionStrings>
ConfigurationManager.ConnectionStrings("SQL1").ConnectionString.ToString
You'll also need to add Imports System.Configuration
is it's not set at the project level.
You can use the ConfigurationManager in System.Configuration
ConfigurationManager.ConnectionStrings("cnnName").ConnectionString;
System.Configuration.ConfigurationManager.ConnectionStrings["SQL1"].ConnectionString
System.Configuration.ConfigurationManager.ConnectionStrings["SQL1"].ToString();
精彩评论