• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 316
  • Last Modified:

VB6: connecting the dots from code to the Data Environment object to a stored proc?

So I've got a stored proc in my SQL Server2K db, and the stored proc is called fred.  
It's expecting an int from the code, and it will return a bunch of records.

I want to put this stored proc into my global Data Environment object (cleverly named "de1"), and then, from the code, call the Data Environment/stored proc (passing an integer), and get the results in a local recordset in my code.

Can someone show me a simple code example (with explanation, preferably) that illustrates these things?

  • 2
1 Solution
edmund_mitchellAuthor Commented:
Leon --

No choice on the DE, unfortunately -- at least for now.   I looked at that URL, and I didn't see anything that related to my question.  A mistake?
Sorry that was a wrong link.  I think you are looking for something like this:

Sub GetRecords()
Dim strSQL as String
    strSQL = "Exec fred " & Text1.Text
    With de1.rsCmd1
        If  .State=adStateOpen  Then .Close
        .Source = strSQL
    End With
    If de1.rsCmd1.EOF and de1.rsCmd1.BOF Then
       MsgBox "There are records"
       MsgBox "There are " & de1.Recordset.RecordCount & " records in the recordset"
    End If
End Sub
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now