开发者

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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜