日期:2014-05-17  浏览次数:20927 次

怎么这么奇怪,请高手回答~~
sql= "select     count( "     &     Pk     &     ")     as     c     from     "     &     table     &     "     "     &     Condition    
其中,Pk= "a.Pid ",table= "Province   a ",Condition= "where     1=1     and     a.Plevel=1 "。    
set     rs=conn.execute(sql)    
报错:    
Microsoft     OLE     DB     Provider     for     ODBC     Drivers     (0x80040E14)    
[Microsoft][ODBC     SQL     Server     Driver][SQL     Server]列前缀     'a '     与查询中所用的表名或别名不匹配。    
 
输出sql语句是:    
select     count(a.Pid)     as     c     from     Province     a     where     1=1     and     a.Plevel=1    
 
那好,我把这个sql语句直接赋值:    
sql= "select     count(a.Pid)     as     c     from     Province     a     where     1=1     and     a.Plevel=1 "    
再次set     rs=conn.execute(sql),正常。。。。    
 
同时,查询分析器查询正常。    
 
请高手回答~~谢谢。急

------解决方案--------------------
这个sql应该没错阿
------解决方案--------------------
本地测试没有问题。。。
------解决方案--------------------
干吗非要select count(a.Pid) as c from Province a where 1=1 and a.Plevel=1 这么写?

select count(Pid) as c from Province where 1=1 and Plevel=1
这样写不行么?