你调用的对象是空的。在 VB.NET 中
我收到此错误:“对象引用未设置为对象的实例。” 在vb.net windows应用程序中sql连接字符串 这是代码:
Dim sqlcon As New SqlConnection(ConfigurationManager.ConnectionStrings("strcon")
.ConnectionString)
我收到此行错误
提前致谢
I got this error : "Object reference not set to an instance of an object."
in vb.net windows application for sql connection string
here is the code:
Dim sqlcon As New SqlConnection(ConfigurationManager.ConnectionStrings("strcon")
.ConnectionString)
I am getting error for this line
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您的 app.config 中似乎没有名为
strcon
的连接字符串。It looks as if there is no connection string named
strcon
in your app.config.您的配置中似乎没有名称为“strcon”的连接字符串...如果 strcon 是代码中的变量,那么您需要从 strcon 中删除“”,如下所示:
It seems that there is no connection string in your config with name "strcon"... in case strcon is a variable in your code then you need to remove the "" from the strcon as shown below:
检查这行代码
是否返回值/出现错误,因为这可能不会返回任何值,即空值,
还有一件事是查看您的配置文件并检查“strcon”名称连接字符串,即
您输入的 是否存在拼写是否正确
Check this line of the code
its returning value or not / error is coming because this may returning no vlaue i.e null value
one more thing have look to your configuration file and check for the "strcon" name connectionstring i.e it exist or not
also you typed correct spell or not
连接字符串:strcon 很可能不存在于您的 app.config 中
the connection string: strcon most likely does not exist in your app.config
如果您在 web.config 中将
strcon
定义为连接字符串,您将收到Null Reference
异常。You would be getting a
Null Reference
Exception Check if you have definedstrcon
as connection string in web.config