DataReader.GetFieldType 返回 null [英] DataReader.GetFieldType returned null

查看:47
本文介绍了DataReader.GetFieldType 返回 null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的数据库表布局中,有一列类型为 hierarchyid(列索引 = 4).在尝试设置新环境(从 XEN 服务器创建的虚拟网络服务器),然后运行该站点时,我遇到了这个问题:

In my db table Layout, there's one column whose type is hierarchyid (column index=4). When trying to set-up new environment (a virtual web-server, created from XEN server), then running the site, I've met with this issue:

异常消息:DataReader.GetFieldType(4) 返回空值.异常数据:System.Collections.ListDictionaryInternal

Exception message: DataReader.GetFieldType(4) returned null. Exception data: System.Collections.ListDictionaryInternal

我进行了一些搜索,发现已经有一些关于它的主题(例如在 MSDN).

I've made some search and found out there are already some topic on it (such as on MSDN).

但即使我添加了 C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies\Microsoft.SqlServer.Types.dll 库,它看起来像结构中的 db 类型 SqlHierarchyId 无法识别.

But even when I added the C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies\Microsoft.SqlServer.Types.dll library, it seems like db type in structure SqlHierarchyId doesn't get recognized.

DataReader.GetFieldType(4) 处的异常返回 null"仍然被抛出.

"Exception at DataReader.GetFieldType(4) returned null" is still thrown out.

注意:如果我将VS2010中的C#包安装到环境(Windows Server 2008 RC2)上,问题将得到解决,但我的老板不接受,因为这纯粹是一个简单的网络服务器.

Note: The issue will be solved if I made installation of C# package in VS2010 onto the environment (Windows Server 2008 RC2), but my boss didn't accept that, because this is purely a simple web-server.

推荐答案

从项目中引用 Microsoft.SQLServer.Types dll,并在引用的属性中将其设置为Copy Local"作为引用.这将在您部署时将该 DLL 与网站打包在一起.那么你不需要在你的 web box 上安装所有的 SQL Server 来使用 SQL Server 数据类型.我为我的网站这样做是因为它使用了 geography 数据类型列,但我遇到了同样的错误.

Reference the Microsoft.SQLServer.Types dll from the project and for the reference set it as "Copy Local" in the properties of the reference. This will package that DLL up with the website when you deploy it. Then you don't need all of SQL Server installed on your web box in order to use the SQL Server data types. I did this for my website because it was using the geography data type columns and I was getting the same error.

这篇关于DataReader.GetFieldType 返回 null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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