such as "select * form report"
however , when i excute a stored procedure error prompt out with
Runtime Error "3021"
either BOF or EOF is True,or the current record has been deleted
I am sure that there is data in the database and the query work fine if i use the SqlAdv to run it.and i am using windowxp SP2 which has mdac 2.8
could anyone tell me how to fix the problem?
the below is my code
Expand|Select|Wrap|Line Numbers
- Private Sub execute_Click()
- Dim Connection As New ADODB.Connection
- Dim Rs As New ADODB.Recordset
- Dim Bs As New ADODB.Recordset
- Dim ExApp As New Excel.Application
- Dim ExWk As New Excel.Workbook
- Dim EXWs As New Excel.Worksheet
- Dim EXRs As Excel.Range
- Dim sql As String
- Set Connection = New ADODB.Connection
- Connection.Open ("DSN=RET_DATA;UID=user;PWD=password")
- Set Rs = Connection.execute("sp_report 20071014,20071015")
- Rs.MoveFirst
- ExApp.Visible = True
- Set ExWk = ExApp.Workbooks.Open("C:\Documents and Settings\ncht\Desktop\test2.xls")
- Set EXWs = ExApp.Worksheets("Sheet2")
- Set EXRs = ExApp.Range("A1")
- EXRs.CopyFromRecordset Rs
- Rs.Close
- End Sub