Recordset 返回正确的行数,但所有字段均为空

发布于 2024-08-09 05:39:13 字数 369 浏览 7 评论 0原文

我现在在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

无人问我粥可暖 2024-08-16 05:39:14

如果没有 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.

浴红衣 2024-08-16 05:39:14
SELECT
    acc.FIRM,
    acc.OFFICE,
    acc.ACCOUNT,
    a.CONV_CODE,
    a.OTHER_AMT AS AMOUNT,
    a.TRANS_DATE,
    a.DESCRIPTN,
    a.JRNAL_TYPE
FROM AccTrans AS a LEFT OUTER JOIN ACC AS acc ON a.ACCNT_CODE = acc.ACCNT_CODE
WHERE
    (acc.SUN_DB = 'IF1') AND
    (ANAL_T0 <> '')  AND
    (a.TRANS_DATE < '20091022') AND
    (a.JRNAL_TYPE = 'MATCH');

这就是视图的定义。事实上,在 Access 中我可以查看此查询的结果,它有数据。这就是为什么我知道记录集返回正确的行数(通过计算代码中的循环)。抱歉我的错误,我在where子句中使用Account,select语句应该像

select Firm, Office, Account, Trans_Date.... from
view_top
where account = 'ABC'

查询返回正确的行数,但所有行数据(甚至帐户字段)都是空字符串。

然后我发现真正导致问题的是 AMOUNT 字段,如果我省略金额,一切正常。虽然我不明白为什么。

SELECT
    acc.FIRM,
    acc.OFFICE,
    acc.ACCOUNT,
    a.CONV_CODE,
    a.OTHER_AMT AS AMOUNT,
    a.TRANS_DATE,
    a.DESCRIPTN,
    a.JRNAL_TYPE
FROM AccTrans AS a LEFT OUTER JOIN ACC AS acc ON a.ACCNT_CODE = acc.ACCNT_CODE
WHERE
    (acc.SUN_DB = 'IF1') AND
    (ANAL_T0 <> '')  AND
    (a.TRANS_DATE < '20091022') AND
    (a.JRNAL_TYPE = 'MATCH');

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

select Firm, Office, Account, Trans_Date.... from
view_top
where account = 'ABC'

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.

亚希 2024-08-16 05:39:14

view_top 定义

“名称、帐户、帐户代码、金额、日期...”

选择语句:

Select Name, Account, AccountCode, Amount, Date 
From View_Top Where Name = 'xxx'

我发现如果省略金额,一切正常。

虽然我还是不明白为什么。

view_top definition

"Name, Account, AccountCode, Amount, Date...."

Select Statements:

Select Name, Account, AccountCode, Amount, Date 
From View_Top Where Name = 'xxx'

I found that if I omit the Amount, everything works.

Though I still don't understand why.

神经大条 2024-08-16 05:39:13

好吧,这个查询对我来说看起来有点错误,尝试使用 ' 而不是 " 来分隔 ABC 字符串...

Well the query looks a little wrong to me, try using ' instead of " to delimit your ABC string...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文