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

ASP中SQL命令求一字段总和
<%    
  Set   Conn=Server.CreateObject( "ADODB.Connection ")      
    Connstr= "DBQ= "+server.mappath( "jdgl.mdb ")+ ";DRIVER={Microsoft   Access   Driver   (*.mdb)}; "      
    Conn.Open   connstr  
   
  Set   Rs   =   Server.CreateObject( "ADODB.RecordSet ")
dj=SELECT   Sum(dj)   FROM   jdgl
rs.Open   dj,conn,0,1      

Response.Write(dj)
%>


上面变量定义有没有错
dj=SELECT   Sum(dj)   FROM   jdgl   这里什么地方错了
在线等   谢谢

------解决方案--------------------
set rs=server.createObject( "adodb.RecordSet ")
rsStr= "select sum(dj) from test "
rs.open rsStr,conn,1,1
Response.Write(rs(0))
rs.close
set rs=nothing
------解决方案--------------------
dj= "SELECT Sum(dj) as sumdj FROM jdgl "
rs.Open dj,conn,1,1

Response.Write(rs( "sumdj "))