Recordset 返回正确的行数,但所有字段均为空
我现在在 3 个城市运行相同的访问副本。他们工作得很好。它们 99% 相同,只有一处细微差别。它们每个都有两个视图,使用不同的 odbc 连接到不同的城市数据库(所有这些数据库都是 SQL Server 2005)。这些视图充当两个非常简单的查询的数据源。
然而,当我尝试为新城市制作新副本时,我发现其中一个简单的内部查询返回正确的行数,但所有数据均为空,而其他查询功能正常。
我检查了这两个视图的数据,数据是正确的。
导致问题的原因就像
Select * from View_Top where Name = "ABC"
记录集返回时一样,即使 rs!Name 也给我一个空字符串。
请帮忙
I have the same copy of access running in 3 cities right now. They work perfectly ok. They are 99% the same with one minor difference. Each of them has two views which use different odbc connection to different cities DB (all these databases are SQL Server 2005). The views act as datasource for some two very simple queries.
However, while I tried to make a new copy for a new city, I found that one of the simple internal query returns the correct number of row but all data are empty while the other query functions correctly.
I checked the data of these two views, the data is correct.
The one causing problem are like
Select * from View_Top where Name = "ABC"
when the recordset returns, even rs!Name give me an empty string.
Please help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果没有 VIEW_TOP 的定义,很难判断错误在哪里,但是如果您获取行但列为 NULL,我猜测 VIEW_TOP (或它所依赖的内容)包含 OUTER JOIN 并且您正在拉动列来自 JOIN 的错误一侧。
Without the definition of VIEW_TOP it's hard to tell where your error is, but if you're getting rows but the columns are NULL I'm guessing that VIEW_TOP (or something it depends on) includes an OUTER JOIN and you're pulling the columns from the wrong side of the JOIN.
这就是视图的定义。事实上,在 Access 中我可以查看此查询的结果,它有数据。这就是为什么我知道记录集返回正确的行数(通过计算代码中的循环)。抱歉我的错误,我在where子句中使用Account,select语句应该像
查询返回正确的行数,但所有行数据(甚至帐户字段)都是空字符串。
然后我发现真正导致问题的是 AMOUNT 字段,如果我省略金额,一切正常。虽然我不明白为什么。
This is the definition of the view. Indeed, in Access i am able to view the result of this query, it has data. that's why i know the recordset returns the correct number of row (by counting the loop in the code). sorry for my mistakes, i use Account in the where clause, the select statements should be like
the query returns the right number of row but all row data (even the account field) are empty string.
then i found out what really cause the problem is the AMOUNT field, if i omit the amount, everything works. though i don't understand why.
view_top 定义
“名称、帐户、帐户代码、金额、日期...”
选择语句:
我发现如果省略金额,一切正常。
虽然我还是不明白为什么。
view_top definition
"Name, Account, AccountCode, Amount, Date...."
Select Statements:
I found that if I omit the Amount, everything works.
Though I still don't understand why.
好吧,这个查询对我来说看起来有点错误,尝试使用 ' 而不是 " 来分隔 ABC 字符串...
Well the query looks a little wrong to me, try using ' instead of " to delimit your ABC string...