vb.net获取web.config中连接字符串
连接字符串如下:
<connectionStrings>
<add name="LocalSqlServer" connectionString="Data Source=Localhost;Initial Catalog=BBS;
Persist Security Info=True;User ID=zcc;Password=123" providerName="System.Data.SqlClient" />
</connectionStrings>
用了如下两种方法获取连接字符串:
Dim con As New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings[""].ToString()
及
protected conn As New SqlConnection(ConfigurationSettings.AppSettings["LocalSqlServer"])
但是都出现了
这个问题,下面再用conn就显出为“未声明”错误了。。 vb.net 连接字符串 web.config
[解决办法]
vb应该是用()不是[]