sql="select sum(字段) as aa from 表名" 如果要统计条数 Dim rst As New ADODB.Recordset sql="select 字段 from 表名" rst.Open sql, conn, adOpenKeyset, adLockPessimistic aa=rs1.RecordCount
Dim Rs As New ADODB.Recordset dim Cn as New ADODB.Connection sql="select count(*) from 表名" Rs.Open sql, Cn, adOpenKeyset, adLockPessimistic aa=rs(0)
Dim Rs As New ADODB.Recordset dim Cn as New ADODB.Connection Rs.Open "select count(*) as aa from 表名", Cn debug.print rs!aa rs.close
Select count(*) as ll from Table 或者用recordset.recordcount也可以。
Select count(*) as ll from Table 或者用recordset.recordcount也可以。同意楼上的!!
如果要统计条数
Dim rst As New ADODB.Recordset
sql="select 字段 from 表名"
rst.Open sql, conn, adOpenKeyset, adLockPessimistic
aa=rs1.RecordCount
dim Cn as New ADODB.Connection
sql="select count(*) from 表名"
Rs.Open sql, Cn, adOpenKeyset, adLockPessimistic
aa=rs(0)
dim Cn as New ADODB.Connection
Rs.Open "select count(*) as aa from 表名", Cn
debug.print rs!aa
rs.close
或者用recordset.recordcount也可以。
或者用recordset.recordcount也可以。同意楼上的!!