我如何解决system.data.dll附加信息中出现的'system.data.sqlclient.sqlexception'类型的第一次机会异常:无效的对象名称" [英] How do I resolve "a first chance exception of type 'system.data.sqlclient.sqlexception' occurred in system.data.dll additional information: invalid object name"

查看:269
本文介绍了我如何解决system.data.dll附加信息中出现的'system.data.sqlclient.sqlexception'类型的第一次机会异常:无效的对象名称"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从数据库表中读取特定的行。这是我试过的VB代码:



I would like to read in a specific row from a database table. Here is the VB code I tried:

Dim sqlQuery As String = String.Format("SELECT * FROM Verification.dbo.VersionValues WHERE VersionID = '{0}'", My.Settings.VersionsVersion)
Dim connStr As String = ConfigurationManager.ConnectionStrings(pConnStringName).ConnectionString
Dim dt As New DataTable

Using conn As New SqlConnection(connStr)
  conn.Open()
  Using dAd As New SqlDataAdapter(sqlQuery, conn)
    dAd.Fill(dt)
  End Using
End Using

Dim val As String = dt(0).Item("LatestUBoot").ToString





尝试执行dAd.Fill(dt)时出现以下错误消息





The following error message occurs when trying to execute line "dAd.Fill(dt)"

Quote:

System.Data.dll中发生'System.Data.SqlClient.SqlException'类型的第一次机会异常



附加信息:无效的对象名称'Verification.dbo.VersionValues'。

A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll

Additional information: Invalid object name 'Verification.dbo.VersionValues'.





我尝试过:



查询在SQL Server Management Studio中有效。



What I have tried:

The query works in SQL Server Management Studio.

推荐答案

已解决:App.config中的连接字符串不正确。
RESOLVED: The connection string in App.config was incorrect.


这篇关于我如何解决system.data.dll附加信息中出现的'system.data.sqlclient.sqlexception'类型的第一次机会异常:无效的对象名称"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆