vb.net - 连接到数据库时正确声明 ConfigurationManager

标签 vb.net configurationmanager

用于连接数据库时出现“ConfigurationManager未声明”错误信息如何解决?

这是给出错误的代码行:

SQLConnStr= ConfigurationManager.ConnectionStrings("SQLConnStr").ConnectionString

最佳答案

您是否尝试过添加引用

  `System.Configuration` 

在您的引用文件夹中。

只需右键单击项目上的引用文件夹,然后单击添加引用..
然后查找 System.Configuration 然后确定。

然后加
Imports System.Configuration 

在你的表格上

将您的应用程序配置更改为:
<connectionStrings> 

<add name="SQLConnStr" connectionString="Data Source=HOTEL_MySQLSERVERR;Initial Catalog=GuestBooking;User ID=xyz;Password=xyz" providerName="System.Data.SqlClient" /> 

</connectionStrings>

//您的应用配置名称和连接字符串名称必须相同

添加名称="SQLConnStr"

连接字符串(“SQLConnStr”)。
SQLConnStr= ConfigurationManager.ConnectionStrings("SQLConnStr").ConnectionString

看看这个:

Fix the Name ‘ConfigurationManager’ is Not Declared Error

问候

关于vb.net - 连接到数据库时正确声明 ConfigurationManager,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5671112/

相关文章:

c# - 从 C# dll 库读取 VB6 项目的 app.config

c# - 即时解密配置,包括 Entity Framework 的连接字符串

c# - App.config 和 ConfigurationManager

c# - 将 C# 代码转换为 VB.NET

.net - 如何验证 .net 框架是否存在,如果不存在如何将其安装在用户计算机上

vb.net - 传递字符串时的 ByRef 与 ByVal 性能

.net - 使用 linq 按列索引对 vb.net 中的数据表进行排序

.net - UserPrincipal.FindByIdentity坚持 "There is no such object on the server."

c# - 在运行时更改 App.config

c# - app.config : how do I make a nested customSection called appSettings be the ConfigurationManager. 应用设置