Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Database Access / May 2008



Tip: Looking for answers? Try searching our database.

Stored Procedure / Get more than one Table back

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Daniel Spanfellner - 29 May 2008 09:03 GMT
Hello,

i have a problem with vb6 and SQL Stored Procedures.

The stored procedure deliver more than one Table back. (Query Analyzer) In
Basic i want to see that. Can you help?

Example:
Stored procedure bring back:
select * from Test
Select * from Test2

In Basic i see only one Result

   Set cda = New ADODB.Command
   cda.ActiveConnection = cn_wO
   cda.CommandTimeout = 400
   cda.CommandType = adCmdStoredProc
   cda.CommandText = "sp_TestSP"

   cda.Parameters.Append cda.CreateParameter("@debug", adInteger,
adParamInput, 50, "1")
   cda.Parameters.Append cda.CreateParameter("@TestPar", adChar,
adParamInput, 50, "hello")

   Set rs_TB = cda.Execute

Greetz

Daniel
Al Reid - 29 May 2008 12:54 GMT
> Hello,
>
[quoted text clipped - 26 lines]
>
> Daniel

Use the NextRecordset Method of the Recordset object  to retrieve the next result set.

After processing the initial result set on rs_TB, do the following:

Set rs_TB = rs_TB.NextRecordset

That should give you what you're looking for.

Signature

Al Reid

Daniel Spanfellner - 29 May 2008 14:38 GMT
Thanks, it works

Dim cda As ADODB.Command
   Dim rs As ADODB.Recordset
   Dim intcount As Integer
   Dim strTemp As String

   Set rs = New ADODB.Recordset
   Set cda = New ADODB.Command
   cda.ActiveConnection = cn_wO
   cda.CommandTimeout = 400
   cda.CommandType = adCmdStoredProc
   cda.CommandText = "dbo.sp_Test"

   cda.Parameters.Append cda.CreateParameter("@Par1", adChar, adParamInput,
20, "Test")
   cda.Parameters.Append cda.CreateParameter("@Par2", adInteger,
adParamInput, 50, "1")
   Set rs = cda.Execute

   intcount = 1
   Do Until rs Is Nothing
        Debug.Print "Contents of recordset #" & intcount
        Debug.Print
"------------------------------------------------------------------------------"
       If rs.State <> 0 Then

       Do Until rs.EOF
           strTemp = ""
           For i = 0 To rs.Fields.Count - 1
               strTemp = strTemp & Trim(rs.Fields(i)) & "|"
           Next i
           Debug.Print strTemp
           rs.MoveNext
       Loop
       End If
       Set rs = rs.NextRecordset
       intcount = intcount + 1
   Loop

>> Hello,
>>
[quoted text clipped - 36 lines]
>
> That should give you what you're looking for.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.