DataReader.GetFieldType返回null(DataReader.GetFieldType returned null)

编程入门 行业动态 更新时间:2024-10-23 14:22:58
DataReader.GetFieldType返回null(DataReader.GetFieldType returned null)

在我的db表格布局中,有一列的类型是hierarchyid (列索引= 4)。 当试图设置新的环境(一个虚拟的Web服务器,由XEN服务器创建),然后运行该网站,我遇到了这个问题:

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

我做了一些搜索,发现已经有一些话题了(比如在MSDN上 )。

但即使当我添加C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies\Microsoft.SqlServer.Types.dll库时,似乎结构SqlHierarchyId中的db类型也不会被识别。

“DataReader.GetFieldType异常(4)返回null”仍然被抛出。

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

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:

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

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

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.

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

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框中安装所有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.

更多推荐

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

发布评论

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

>www.elefans.com

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