Solved

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

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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Exit a vb6 apps when a calling it apps closes 15 49
MsgBox 4 61
What .NET URL re-routing tool did I use? 2 56
VIDEO DATASOURCE Control Resize issue 2 20
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…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

821 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