土耳其语 Window server 2008 安装中来自 DataRow.Item() 的 ArgumentException
我们的软件安装在土耳其的(客户站点)Window Server 2008 R2 Foundation 上(因此区域设置设置为土耳其语,因此所有菜单和消息都以土耳其语显示)。我们使用的是 SQL Server 2005 Express。数据库排序规则为SQL_Latin1_General_CP1_CI_AI
(与我们其他英语安装站点中的一样)。
我们的代码通过一个简单的查询来查询数据库:select * form tableName where callid='variable'
(callid是我们的主键,但是数据库中的列名是CallID,列类型是varchar(60)
),使用 SqlDataAdapter.Fill()
方法填充我们的非类型化 DataSet
。
我们从 DataSet.Tables[0].Rows[0]
生成 DataRow
对象。我们将此 DataRow 对象传递给其他方法,并使用 DataRow .Item(字符串) 获取列值。我们有几个列,我们可以通过这种方式毫无问题地获取它们的值。然而,对于一个特定的列,我们得到
ArgumentException: <column name> column does not belong to table Table
此列是我们的 callid 列! 当我们将数据库中的列名称更改为 callid 或 CalliD 时,我们不会收到异常。 我看过这篇名为 介绍一下土耳其语I问题,据我了解,文章地址是当collation = TURKISH_CI_AS时的问题。
我在这里缺少什么? 我将不胜感激任何有用的意见。
谢谢,伊兰
Our software was installed on (customer site) Window Server 2008 R2 Foundation in Turkey (So locale is set to Turkish, and thus all menus and messages are displayed in Turkish). We are using SQL server 2005 express. The database collation is SQL_Latin1_General_CP1_CI_AI
(as in our other English installed sites).
Our code query the database with a simple query: select * form tableName where callid='variable'
(callid is our primary key, however the column name in the database is CallID, column type is varchar(60)
), using SqlDataAdapter.Fill()
method to fill our untyped DataSet
.
We yield the DataRow
object from DataSet.Tables[0].Rows[0]
. We pass this DataRow
object to other methods and we use DataRow.Item (String) to get the columns values. We have several columns that we get their values this way with no problems. However for one particular column we get
ArgumentException: <column name> column does not belong to table Table
This column is our callid column!
When we change the column name in database to callid, or CalliD we don't get the exception.
I've seen this article called Introduce the Turkish I issue and as I understand it the issue the article address is when collation = TURKISH_CI_AS.
What am I missing here?
I'd appreciate any helpful input.
Thanks, Ilan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的猜测是,问题根本不是发生在数据库端,而是当本地代码(
DataSet
)正在寻找您的柱子。最简单的解决方法可能是使用列序号值而不是名称。出于诊断目的,我建议您查看
DataTable.Columns
并尝试各种方法以不区分大小写/区域性的方式匹配名称。如果您事先不知道序号,那么您可能希望以这种方式动态查找它,如果使用DataSet
查找它失败:(My guess is that the problem isn't occurring on the database side at all, but when the local code (
DataSet
) is looking for your column.The simplest fix is probably to use the column ordinal value instead of the name. For diagnostic purposes, I suggest you look through the column names returned by
DataTable.Columns
and try various approaches to match the name in a case/culture-insensitive way. If you don't know the ordinal up-front, you might want to find it that way dynamically, if getting theDataSet
to find it fails :(