DataReader.GetFieldType 返回 null

编程入门 行业动态 更新时间:2024-10-25 02:29:32
本文介绍了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

本文发布于:2023-05-31 10:05:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/389542.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:DataReader   GetFieldType   null

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!