为什么的recorcount不是-1就是1呢?救急啊
Private Sub Form_Load()Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sql As String
Dim a As Long
conn.Open "PROVIDER=Microsoft.jet.OLEDB.4.0;data source=" & App.Path & "\chehao.mdb"
rs.Open "select count(*) from [chehao]", conn, adOpenKeyset, adLockReadOnly
a=rs.RecordCount
rs.Close
MsgBox a
Set rs = Nothing
Set conn = Nothing
End Sub --------------------编程问答-------------------- 这样的sql,只可能返回1或者-1,有数据就是1,没有数据就是-1
你如果想知道里面的值
"select isnull(count(*) ,0) from [chehao] "
...
a=rs.fields(0)
补充:VB , 数据库(包含打印,安装,报表)