SQL 数据表错误“值不能为空”。
我正在执行 sql 查询,并且收到错误值不能为空。 参数名称:dataTable
代码:
strSQLHost = "select HostBase.AppName from HostBase where HostBase.appid=0"
Dim dtHost As DataTable
Dim daHost As SqlDataAdapter = New SqlDataAdapter(strSQLHost, conn)
daHost.Fill(dtHost)
错误发生在daHost.Fill(dtHost)
当我在 SQL Enterprise 管理器中运行此查询时,我得到的值为“无”。这是一个有效值,而不是空值。
我该如何解决这个问题?
I am executing a sql query, and I am getting an error Value cannot be null.
Parameter name: dataTable
Code:
strSQLHost = "select HostBase.AppName from HostBase where HostBase.appid=0"
Dim dtHost As DataTable
Dim daHost As SqlDataAdapter = New SqlDataAdapter(strSQLHost, conn)
daHost.Fill(dtHost)
The error occurs at the daHost.Fill(dtHost)
When I run this query in SQL Enterprise manager, I get a value of 'None'. It's a valid value, not a null value.
How can I resolve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
删除语句中的最后一个
'
我认为它应该这样读:
并在传入之前实例化您的 DataTable:
remove the last
'
on your statementI think it should read like this:
And instantiate your DataTable before passing it in:
当您仅引用一个表:HostBase 时,似乎您正在混合表名称。您不能在此查询中使用 table: Host 而不将其包含在某种联接中(即使它变成笛卡尔积),这就是更改。
打断一下,查看字符串变量的确切值:strSQLHost
Seems like you're mixing table names when you only refer to one table: HostBase. You can't use table: Host in this query without including it in some sort of join (Even if it turned into a Cartesian Product) This is the change.
Put a break and see the exact value of the string variable: strSQLHost