Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

VB6 Stored proc problem :-(

Options
  • 11-04-2007 5:26pm
    #1
    Closed Accounts Posts: 884 ✭✭✭


    Ok heres some over simplified sample code code of my problem
      SELECT @CMD = ' SELECT user from Users'
      EXECUTE( @CMD)
    


    Works great returns 3 records. Works in crystal reports job done i thought :(


    Here's the problem i try the following and i haven't touched vb6 in years.

        Dim sSQL As String
        Dim oCmd As New ADODB.Command
        Dim rs As New ADODB.Recordset
    
        With oCmd
            .ActiveConnection = dbCon                               'Allow the command object to use the currently open db connection
            .CommandType = adCmdStoredProc                          'Set the command type to be the stored procedure
            .CommandText = "Rpt__STORED_PROC"      'Set the stored procedure to be used
            .Parameters.Append .CreateParameter("@SearchType", adVarChar, adParamInput, 50, SearchType)
        
           
        Set rs = .Execute               
        End With
        
        'rs.Open oCmd, ,adOpenForwardOnly,adLockReadOnly,
        'rs.Open oCmd,,adOpenStatic,adLockReadOnly,
    
    
         'rs.CursorLocation = adUseClient
         'rs.Open sSQL, dbCon, adOpenForwardOnly, adLockReadOnly
        
        'Set rs.ActiveConnection = Nothing
        Set GetFUMRSearchResults = rs
    
    

    Any ideas why vb returns a closed recordset. i cant even get a snapshot and iv re-jigged the code a few times now


Comments

  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    I'm assuming SearchType is a parameter passed into the function, if its not then that might be your problem. I can't remember vb6 either but if you have sql profiler you may want to look at what the call is doing on the DB side.


  • Closed Accounts Posts: 884 ✭✭✭NutJob


    Took yesterday off sick:(



    The solution.
    http://support.microsoft.com/default.aspx/kb/235340

    Added following to stored proc
    SET NOCOUNT ON
    


  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    Glad you found your solution.

    You'll notice, incidentally, that the "simplified" example you gave shouldn't actually cause this problem.


Advertisement