Solved

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

Posted on 2004-03-28
2
268 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now