VB database connection problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ncht
    New Member
    • Oct 2007
    • 2

    VB database connection problem

    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]
    Last edited by debasisdas; Oct 24 '07, 07:40 AM. Reason: Formatted using code tags
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Is the procedure returning any value when executed independently at database level ?

    Comment

    • ncht
      New Member
      • Oct 2007
      • 2

      #3
      the procedure does return the field and the properties when i run the debug mode and add watch on the result set yet both the BOF and EOF set to True



      and when i execute another query it can also extract the recordset into the excel file...

      thanks for your reply ^^

      Comment

      Working...