选择Qry:通过Access& amp;和ADO(& SQL Server) [英] Select Qry: Differing results via Access & ADO (& SQL Server)

查看:78
本文介绍了选择Qry:通过Access& amp;和ADO(& SQL Server)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个查询在Access查询构建器中生成不同的结果

和ASP页面(通过ADO)


查询示例是:

---------------------------------------- ------------------

选择''Ranked''作为Source,H.HotelName,H.TelNo,H.URL,H.Location ,

H.HotelID,排名

来自(酒店H Inner加入PrefHotels P on H.HotelID = P.HotelID)

内部加入地点L on P.LocID = L.LocID

其中Rank不为空且Rank> 0和L.LocID = 2


联盟


选择''Unranked''作为Source,H.HotelName,H.TelNo,H .URL,H.Location,

H.HotelID,Rank

来自(酒店H Inner加入PrefHotels P on H.HotelID = P.HotelID)

内部加入位置L在P.LocID上= L.LocID

其中(Rank为Null或Rank = 0)和L.LocID = 2


按来源排序,排名

------------------------------------ ----------------------


在Access中,我得到以下结果


排名,酒店1,[其他领域],1

排名,酒店2,[其他领域],2

排名,酒店3,[其他领域],3

未评级,酒店4,[其它领域],0

未评级,酒店4,[其他领域],0

未评级,酒店4,[其他字段],0

等...


在我的ASP页面中,我得到以下结果:


未评级,酒店1,[其它领域],

未评级,酒店2,[其它领域],

未评级,酒店3 ,[其它领域],

未评级,酒店4,[其它领域],

未评级,酒店4,[其它领域],

未评级, Hotel4,[其他领域],

等...


我已将Access DB导入SQL Server,并在查询分析器和

ASP页面我得到了正确的结果:

排名,酒店1,[其他领域],1

排名,酒店2,[其它领域] ,2

排名,酒店3,[其它领域],3

未评级,酒店4,[其它领域],0

未评级,Hotel4, [其他领域],0

未评级,酒店4,[其他领域],0

等...


(即与Access相同)


我假设如果Access本身不反对SQL,那么它必须是

吧。因此,问题在于ADO和Access OLEDB驱动程序......


有什么想法吗?


Chris

解决方案

所以你在ASP页面中没有看到查询中的[Rank]?您使用什么代码

来显示记录集值?


-


雷在家里/>
Microsoft ASP MVP

" CJM" < CJ ***** @ yahoo.co.uk>在消息中写道

新闻:%2 ****************** @ TK2MSFTNGP09.phx.gbl ...

我有一个查询,它在Access查询
构建器和ASP页面(通过ADO)中产生不同的结果

查询的一个例子是:
----- -------------------------------------------------- ---
选择''排名''作为来源,H.HotelName,H.TelNo,H.URL,H.Location,
H.HotelID,Rank
来自(Hotels H Inner)加入H.HotelID = P.HotelID上的PrefHotels P
P.LocID = L.LocID上的内部加入位置L其中Rank不为空并且Rank> 0和L.LocID = 2

联盟

选择''Unranked''作为Source,H.HotelName,H.TelNo,H.URL,H.Location,< H.HotelID,Rank
来自(酒店H Inner加入PrefHotels P on H.HotelID = P.HotelID)
内部加入地点L on P.LocID = L.LocID
其中(等级为空或等级= 0)和L.LocID = 2

按来源排序,等级
------------------ ----------------------------------------

在Access中,我得到以下结果

排名,酒店1,[其他领域],1
排名,酒店2,[其它领域],2
排名,酒店3,[其他领域] ,3
未评级,酒店4,[其他领域],0
未评级,酒店4,[其他领域],0
未评级,酒店4,[其他领域],0
等..

在我的ASP页面中,我得到以下结果:

未评级,酒店1,[其他领域],
未评级,酒店2,[其他领域],<没有收费,酒店3,[其他领域],
未评级,酒店4,[其他领域],
未评级,酒店4,[其他领域], Unranked,Hotel4,[其他领域],
等...

我已将Access DB导入SQL Server,并在Query Analyzer和
中导入ASP页面我得到了正确的结果:
排名,酒店1,[其他领域],1
排名,酒店2,[其他领域],2
排名,酒店3,[其他领域], 3
未评级,酒店4,[其他领域],0
未评级,酒店4,[其他领域],0
未评级,酒店4,[其他领域],0
等.. 。

(即与访问中相同)

我假设如果Access本身不反对SQL,它必须是正确的。因此,问题在于ADO和Access OLEDB
驱动程序......
任何想法?

Chris



Ray,


我将为您提供全表结构,但在调试过程中,我已经添加了一个b $ b在oConn.Execute之后这样直线:


用rs

Response.Write .fields(0)& "," &安培; .fields(1)& "," &安培; .......&

..fields(7)

结束


显然它出来了as:


未评级,酒店名称,...其他详细信息......,< = No Rank

value


Chris


" Ray at<%= sLocation%> [MVP] QUOT; <私人支持请求太多 - 如果需要请求

>在消息中写道

新闻:%2 ****************** @ TK2MSFTNGP09.phx.gbl ...

所以你在ASP页面中没有看到查询中的[Rank]?你用什么代码来显示记录集值?


雷在家
微软ASP MVP


你能告诉我们你得到了什么

response.write rs.GetString(2 ,," |" ;,"< BR>")

Bob Barrows

CJM写道:

Ray,

我会饶你全桌结构,但是在调试过程中,我在oConn.Execute之后直接添加了这样的一行:

用rs
Response.Write .fields(0)& "," &安培; .fields(1)& "," &安培; .......&
.fields(7)
结束

显然它出现了:

未评级,酒店名称,...其他细节......,< = No
等级值

Chris

< Ray at<%= sLocation%> [MVP] QUOT; <太多私人支持请求 -
如果需要请求>在消息中写道
新闻:%2 ****************** @ TK2MSFTNGP09.phx.gbl ...

所以你不是'在ASP页面中查看查询中的[Rank]?您用什么代码来显示记录集值?


雷在家
Microsoft ASP MVP




-

Microsoft MVP - ASP / ASP.NET

请回复新闻组。这个电子邮件帐户是我的垃圾邮件陷阱所以我

不经常检查它。如果您必须离线回复,请删除

无垃圾邮件


I have a query which produces different results in the Access query builder
and in an ASP page (via ADO)

An example of the query is:
----------------------------------------------------------
Select ''Ranked'' as Source, H.HotelName, H.TelNo, H.URL, H.Location,
H.HotelID, Rank
from (Hotels H Inner Join PrefHotels P on H.HotelID = P.HotelID)
Inner Join Locations L on P.LocID = L.LocID
where Rank is not null and Rank > 0 and L.LocID=2

Union

Select ''Unranked'' as Source, H.HotelName, H.TelNo, H.URL, H.Location,
H.HotelID, Rank
from (Hotels H Inner Join PrefHotels P on H.HotelID = P.HotelID)
Inner Join Locations L on P.LocID = L.LocID
where (Rank is Null or Rank = 0) and L.LocID=2

Order By Source, Rank
----------------------------------------------------------

In Access, I get the following results

Ranked, Hotel1, [other fields], 1
Ranked, Hotel2, [other fields], 2
Ranked, Hotel3, [other fields], 3
Unranked, Hotel4, [other fields], 0
Unranked, Hotel4, [other fields], 0
Unranked, Hotel4, [other fields], 0
etc...

In my ASP Page I get these results:

Unranked, Hotel1, [other fields],
Unranked, Hotel2, [other fields],
Unranked, Hotel3, [other fields],
Unranked, Hotel4, [other fields],
Unranked, Hotel4, [other fields],
Unranked, Hotel4, [other fields],
etc...

I''ve imported the Access DB to SQL Server, and in Query Analyser and in the
ASP page I get the right result:
Ranked, Hotel1, [other fields], 1
Ranked, Hotel2, [other fields], 2
Ranked, Hotel3, [other fields], 3
Unranked, Hotel4, [other fields], 0
Unranked, Hotel4, [other fields], 0
Unranked, Hotel4, [other fields], 0
etc...

(ie Same as in Access)

I''m assuming that if Access itself doesnt object to the SQL, it must be
right. Therefore, the problem lies with ADO and the Access OLEDB drivers...

Any ideas?

Chris

解决方案

So you aren''t seeing [Rank] from your query in your ASP pages? What code
are you using to display the recordset values?

--

Ray at home
Microsoft ASP MVP
"CJM" <cj*****@yahoo.co.uk> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...

I have a query which produces different results in the Access query builder and in an ASP page (via ADO)

An example of the query is:
----------------------------------------------------------
Select ''Ranked'' as Source, H.HotelName, H.TelNo, H.URL, H.Location,
H.HotelID, Rank
from (Hotels H Inner Join PrefHotels P on H.HotelID = P.HotelID)
Inner Join Locations L on P.LocID = L.LocID
where Rank is not null and Rank > 0 and L.LocID=2

Union

Select ''Unranked'' as Source, H.HotelName, H.TelNo, H.URL, H.Location,
H.HotelID, Rank
from (Hotels H Inner Join PrefHotels P on H.HotelID = P.HotelID)
Inner Join Locations L on P.LocID = L.LocID
where (Rank is Null or Rank = 0) and L.LocID=2

Order By Source, Rank
----------------------------------------------------------

In Access, I get the following results

Ranked, Hotel1, [other fields], 1
Ranked, Hotel2, [other fields], 2
Ranked, Hotel3, [other fields], 3
Unranked, Hotel4, [other fields], 0
Unranked, Hotel4, [other fields], 0
Unranked, Hotel4, [other fields], 0
etc...

In my ASP Page I get these results:

Unranked, Hotel1, [other fields],
Unranked, Hotel2, [other fields],
Unranked, Hotel3, [other fields],
Unranked, Hotel4, [other fields],
Unranked, Hotel4, [other fields],
Unranked, Hotel4, [other fields],
etc...

I''ve imported the Access DB to SQL Server, and in Query Analyser and in the ASP page I get the right result:
Ranked, Hotel1, [other fields], 1
Ranked, Hotel2, [other fields], 2
Ranked, Hotel3, [other fields], 3
Unranked, Hotel4, [other fields], 0
Unranked, Hotel4, [other fields], 0
Unranked, Hotel4, [other fields], 0
etc...

(ie Same as in Access)

I''m assuming that if Access itself doesnt object to the SQL, it must be
right. Therefore, the problem lies with ADO and the Access OLEDB drivers...
Any ideas?

Chris



Ray,

I''ll spare you the full table structure, but in the debugging process, I
added a line like this straight after the oConn.Execute:

With rs
Response.Write .fields(0) & "," & .fields(1) & "," & ....... &
..fields(7)
End With

And obviously it came out as:

Unranked, Hotelname, ...other details... , <= No Rank
value

Chris

"Ray at <%=sLocation%> [MVP]" <Too many private support requests - Ask for
it if needed> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...

So you aren''t seeing [Rank] from your query in your ASP pages? What code
are you using to display the recordset values?

--

Ray at home
Microsoft ASP MVP



Could you show us what you get with

response.write rs.GetString(2,," | ", "<BR>")

Bob Barrows
CJM wrote:

Ray,

I''ll spare you the full table structure, but in the debugging
process, I added a line like this straight after the oConn.Execute:

With rs
Response.Write .fields(0) & "," & .fields(1) & "," & ....... &
.fields(7)
End With

And obviously it came out as:

Unranked, Hotelname, ...other details... , <= No
Rank value

Chris

"Ray at <%=sLocation%> [MVP]" <Too many private support requests -
Ask for it if needed> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...

So you aren''t seeing [Rank] from your query in your ASP pages? What
code are you using to display the recordset values?

--

Ray at home
Microsoft ASP MVP



--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don''t check it very often. If you must reply off-line, then remove the
"NO SPAM"


这篇关于选择Qry:通过Access&amp; amp;和ADO(&amp; SQL Server)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆