我的一条关于数据库多表查询的sql语句,在数据库管理系统的query中执行成功,而同样的语句放在vb程序中,却返回空记录集,程序如下:
dim cnn as new adodb.connection
假定此cnn对象已正确打开,即正确连接数据库
dim rs as new adodb.recordset
dim strsql as string
'假定此strsql字符串即是在数据库管理系统中正确执行的sql语句
set rs=cnn.execute(strsql)
执行完此语句后,rs对象的EOF或BOF属性总是True,即没有满足条件的记录集,但事实上是有的。注:该sql语句特点:多表连接,用了count(*),group by,order by字句;
当该sql语句变为简单语句如:“select * from Table_naem"时,不存在上面的问题我的Sql语句为:
select a.ClassID,a.ClassName,count(*) from a,b,c where c.SchoolsiteID=2 and b.SiteID=c.SiteID and b.
ClassID=a.ClassID group by a.ClassID order by a.ClassID
期中a,b,c为表名。
dim cnn as new adodb.connection
假定此cnn对象已正确打开,即正确连接数据库
dim rs as new adodb.recordset
dim strsql as string
'假定此strsql字符串即是在数据库管理系统中正确执行的sql语句
set rs=cnn.execute(strsql)
执行完此语句后,rs对象的EOF或BOF属性总是True,即没有满足条件的记录集,但事实上是有的。注:该sql语句特点:多表连接,用了count(*),group by,order by字句;
当该sql语句变为简单语句如:“select * from Table_naem"时,不存在上面的问题我的Sql语句为:
select a.ClassID,a.ClassName,count(*) from a,b,c where c.SchoolsiteID=2 and b.SiteID=c.SiteID and b.
ClassID=a.ClassID group by a.ClassID order by a.ClassID
期中a,b,c为表名。
在SQL Server Query里执行有没有记录?
怎么精简sqlstring?
请问大家哪mysql的windowsODBC驱动! 我不怎么会! 请大家帮我!
ClassID=a.ClassID group by a.ClassID order by a.ClassID在group by a.ClassID order by 的a.ClassID 后面改为a.ClassID,a.ClassName试试