Private Sub Form_Load()
Dim cn As New RDO.rdoConnection
Dim rst As RDO.rdoResultset
Set cn = rdoEngine.rdoEnvironments(0).OpenConnection("erp")
Set rst = cn.OpenResultset("select * from cust;")
rst.MoveLast
rst.MoveFirst
For i = 1 To rst.RowCount
    Debug.Print rst.rdoColumns(0)
    rst.MoveNext
Next i
Set rst = Nothing
Set cn = NothingEnd Sub
为什么出错呀 说什么 cursor was not declared 
cursor 是不是游标呀?

解决方案 »

  1.   

    ADO的:
        Dim SQL As String
        Dim conn As New ADODB.Connection
        
        conn.Open "Provider=SQLOLEDB.1;Persist Security Info=True;User ID=sa;Password=111;Initial Catalog=abc;Data Source=computer"    
        Dim rs As New ADODB.Recordset
        Set rs.ActiveConnection = conn
        
        SQL = "select city_code,city_name,b.country_code,"
        SQL = SQL & "b.country_name from city a,country b where "
        SQL = SQL & "a.country_code=b.country_code"
        
        rs.Source = SQL
        rs.Open