Dim a As Integer Dim rs As New ADODB.Recordset Dim isql As String isql = "SELECT COUNT(*) FROM T_MATERIAL" rs.Open isql, cnn, adOpenStatic a = rs(0) MsgBox a rs.Close
dim rs as new adodb.recordset dim cn as new adodb.connection cn.open "" '数据库连接字符串dim strsql as string strsql="SELECT COUNT(*) FROM... " rs.open strsql,cn,3,3 if not rs.eof then debug.print rs.fields(0).value '用rs.fields(0) 访问 end if rs.close set rs=nothing cn.close set cn=nothing 或者: dim rs as new adodb.recordset dim cn as new adodb.connection cn.open "" '数据库连接字符串dim strsql as string strsql="SELECT COUNT(*) as AllCount FROM... " rs.open strsql,cn,3,3 if not rs.eof then debug.print rs.fields("AllCount").value ' end if rs.close set rs=nothing cn.close set cn=nothing
Dim rs As New ADODB.Recordset
Dim isql As String
isql = "SELECT COUNT(*) FROM T_MATERIAL"
rs.Open isql, cnn, adOpenStatic
a = rs(0)
MsgBox a
rs.Close
dim rs as new adodb.recordset
dim cn as new adodb.connection
cn.open "" '数据库连接字符串dim strsql as string
strsql="SELECT COUNT(*) FROM... "
rs.open strsql,cn,3,3
if not rs.eof then
debug.print rs.fields(0).value '用rs.fields(0) 访问
end if
rs.close
set rs=nothing
cn.close
set cn=nothing 或者:
dim rs as new adodb.recordset
dim cn as new adodb.connection
cn.open "" '数据库连接字符串dim strsql as string
strsql="SELECT COUNT(*) as AllCount FROM... "
rs.open strsql,cn,3,3
if not rs.eof then
debug.print rs.fields("AllCount").value '
end if
rs.close
set rs=nothing
cn.close
set cn=nothing