Results 1 to 20 of 20

Thread: [RESOLVED] SPROC and VB6 Question

Threaded View

  1. #1

    Thread Starter
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Resolved [RESOLVED] SPROC and VB6 Question

    I have the following SPROC:

    VB Code:
    1. USE IADATA
    2. IF EXISTS (select * from syscomments where id = object_id ('TestSP'))
    3.     DROP PROCEDURE TestSP
    4.  
    5. GO
    6. CREATE PROCEDURE TestSP
    7.     /*Declare Variables*/
    8.     @ListStr varchar(100) /*Hold Delimited String*/
    9. AS
    10.  
    11. DECLARE @ListTbl Table (InvUnit varchar(50)) /*Creates Temp Table*/
    12. DECLARE @CP int /*Len of String */
    13. DECLARE @SV varchar(50) /*Holds Result */
    14.  
    15. While @ListStr<>''
    16. Begin
    17.     Set @CP=CharIndex(',',@ListStr) /*Sets length of words - Instr */
    18.     If @CP<>0
    19.     Begin
    20.         Set @SV=Cast(Left(@ListStr,@CP-1) as varchar) /*Copies Portion of String*/
    21.         Set @ListStr=Right(@ListStr,Len(@ListStr)-@CP) /*Sets up next portion of string*/
    22.     End
    23.     Else
    24.     Begin
    25.         Set @SV=Cast(@ListStr as varchar)
    26.         Set @ListStr=''
    27.     End
    28.     Insert into @ListTbl Values (@SV) /*Inserts variable into Temp Table*/
    29. End
    30.  
    31. Select InvUnit From @ListTbl LT
    32. INNER Join dbo.Incidents ST on ST.Inv_Unit=LT.InvUnit

    and I am using the following VB code to access the SPROC:

    VB Code:
    1. Private Sub Command1_Click()
    2. Dim adoConn As ADODB.Connection
    3. Dim adoCmd As ADODB.Command
    4. Dim adoRS As ADODB.Recordset
    5. Dim strLegend As String
    6. Dim strData As String
    7.  
    8. Set adoConn = New ADODB.Connection
    9. adoConn.Open connString
    10.  
    11. Set adoRS = New ADODB.Recordset
    12. Set adoCmd = New ADODB.Command
    13.  
    14. With adoCmd
    15.     Set .ActiveConnection = adoConn
    16.     .CommandText = "TestSP"
    17.     .CommandType = adCmdStoredProc
    18.     .Parameters.Append .CreateParameter("ListStr", adVarChar, adParamInput, 100)
    19.     .Parameters("ListStr").Value = "Unit 41,Unit 32,Unit 34,Unit 54"
    20.    
    21.     Set adoRS = .Execute
    22.    
    23.     Do While Not adoRS.EOF
    24.         Debug.Print adoRS.Fields(0).Value
    25.     Loop
    26.    
    27. End With
    28.  
    29. adoRS.Close
    30. Set adoRS = Nothing
    31. Set adoCmd = Nothing
    32. adoConn.Close
    33. Set adoConn = Nothing
    34.  
    35. End Sub

    I get an operation not allowed when object is closed error on the:

    VB Code:
    1. Do While Not adoRS.EOF

    line. Any ideas?

    Thanks!
    Last edited by Mark Gambo; May 14th, 2006 at 03:52 AM.
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width