Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

911 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

22 Experts available now in Live!

Get 1:1 Help Now