Solved

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

Posted on 2004-03-28
2
287 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

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