i am facing a database connectiion problem that i have writen code with connect to the database using ADODB , and i am sure that the connection is made an execution of query can be done succefully with some common query
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
[code=vb]
Private Sub execute_Click()
Dim Connection As New ADODB.Connectio n
Dim Rs As New ADODB.Recordset
Dim Bs As New ADODB.Recordset
Dim ExApp As New Excel.Applicati on
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.Connectio n
Connection.Open ("DSN=RET_DATA; UID=user;PWD=pa ssword")
Set Rs = Connection.exec ute("sp_report 20071014,200710 15")
Rs.MoveFirst
ExApp.Visible = True
Set ExWk = ExApp.Workbooks .Open("C:\Docum ents and Settings\ncht\D esktop\test2.xl s")
Set EXWs = ExApp.Worksheet s("Sheet2")
Set EXRs = ExApp.Range("A1 ")
EXRs.CopyFromRe cordset Rs
Rs.Close
End Sub
[/code]
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
[code=vb]
Private Sub execute_Click()
Dim Connection As New ADODB.Connectio n
Dim Rs As New ADODB.Recordset
Dim Bs As New ADODB.Recordset
Dim ExApp As New Excel.Applicati on
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.Connectio n
Connection.Open ("DSN=RET_DATA; UID=user;PWD=pa ssword")
Set Rs = Connection.exec ute("sp_report 20071014,200710 15")
Rs.MoveFirst
ExApp.Visible = True
Set ExWk = ExApp.Workbooks .Open("C:\Docum ents and Settings\ncht\D esktop\test2.xl s")
Set EXWs = ExApp.Worksheet s("Sheet2")
Set EXRs = ExApp.Range("A1 ")
EXRs.CopyFromRe cordset Rs
Rs.Close
End Sub
[/code]
Comment