Solved

Visual Basic app to read the text of a SQL Server 2000 stored procedure

Posted on 2004-03-28
2
283 Views
Last Modified: 2013-11-25
I have a Visual Basic application that uses ADO to call a stored procedure to send orders for a client.

The orders are sent in batches.  (A "batch" is one transmission to the vendor.)
There are usually about 10 orders per batch.   The number of orders per batch are controlled in the stored procedure by the use of the "TOP XX" parameter in the SELECT statement.   For example:

    SELECT TOP 10 OrderID, OrderName, ..."

PROBLEM:  I want my front end Visual Basic application to extract the number (it is "10" in my example) from the stored procedure and display it to the users.

 They need this capability to give them a visual clue to change the stored procedure if they need to change the number of orders per batch.

(I realize that we can send this value to the stored procedure as a parameter and we may do that later.)

QUESTION:  Is it possible to extract hard-coded information from the raw text of a stored procedure?
0
Comment
Question by:EasyAim
2 Comments
 
LVL 4

Accepted Solution

by:
trkcorp earned 65 total points
ID: 10701414
You can use sp_helptext to return the text of the SP and read it line by line, for example:

Private Sub Command1_Click()
Dim Cn As ADODB.Connection
Dim rs As ADODB.Recordset
Set Cn = New ADODB.Connection
Cn.Open "DSN=YOURData", "YOUR_ID", "YOUR_PW"
Set rs = New ADODB.Recordset
rs.Source = "exec sp_helptext sp_YOUR_STORED_PROC"
rs.Open , Cn, adOpenForwardOnly, , adCmdText
If Not rs.EOF And Not rs.BOF Then
  rs.MoveFirst
  Do Until rs.EOF
    MsgBox rs.Fields(0)
    rs.MoveNext
  Loop
End If
  rs.Close
  Set rs = Nothing
  Cn.Close
  Set Cn = Nothing
End Sub

And move to that string of text.

You could also just return the value along with the recordset you are curently getting...
0
 

Author Comment

by:EasyAim
ID: 10703216
wow, I'll give it a try today.

{I meant to mention:  SQL Server 2000 }
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question