473,386 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Stored Procedure and SQL String????

Can someone please tell me if it is possible to get the SQL statement from a
stored procedure in ASP.NET?

Dim Myconn As New SqlConnection(ConfigurationSettings.AppSettings("s trConn"))
Dim cmd As New SqlCommand("MenuItems", Myconn)
cmd.CommandType = CommandType.StoredProcedure

I would like to beable to get the SQL statement of "MenuItems" as a string
and use it in another part of my code... How do I do this???
EG:
Dim baseSQL As String = 'meuItems value
Dim SQL As String = baseSQL.Replace("@ParentID", "0")
...CODE...
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then

Dim Myconn As New
SqlConnection(ConfigurationSettings.AppSettings("s trConn"))
Dim cmd As New SqlCommand("MenuItems", Myconn)
cmd.CommandType = CommandType.StoredProcedure

Myconn.Open()

Dim baseSQL As String = 'meuItems value
Dim SQL As String = baseSQL.Replace("@ParentID", "0")

'OK
Dim oDataReader As SqlDataReader = cmd.ExecuteReader()
Dim oMenuItem As skmMenu.MenuItem = Nothing
Dim iOrdinal As Integer = -1
Dim myID As Long = 0
While oDataReader.Read
oMenuItem = New skmMenu.MenuItem
iOrdinal = oDataReader.GetOrdinal("Text")
oMenuItem.Text = oDataReader.GetString(iOrdinal)
iOrdinal = oDataReader.GetOrdinal("ToolTip")
oMenuItem.ToolTip = oDataReader.GetString(iOrdinal)
iOrdinal = oDataReader.GetOrdinal("Url")
oMenuItem.Url = oDataReader.GetString(iOrdinal)
iOrdinal = oDataReader.GetOrdinal("ID")
myID = Long.Parse(oDataReader.GetValue(iOrdinal).ToString )
iOrdinal = oDataReader.GetOrdinal("SubMenuItemsCount")
If oDataReader.GetInt32(iOrdinal) > 0 Then
LoadSubMenu(oMenuItem, baseSQL, myID)
End If
mnuMain.Items.Add(oMenuItem)
End While
mnuMain.CssClass = "menustyle"
mnuMain.HighlightTopMenu = True
mnuMain.Opacity = "100"
mnuMain.zIndex = 1000
mnuMain.Cursor = skmMenu.MouseCursor.Pointer

oDataReader.Close()
Myconn.Close()
End If
End Sub
Nov 19 '05 #1
2 2346
Instead of replacing use this:

cmd.Parameters.Add("@ParentID", SqlDbType.Integer);
cmd.Parameters["@ParentID"].Value = 0;

"Tim::.." wrote:
Can someone please tell me if it is possible to get the SQL statement from a
stored procedure in ASP.NET?

Dim Myconn As New SqlConnection(ConfigurationSettings.AppSettings("s trConn"))
Dim cmd As New SqlCommand("MenuItems", Myconn)
cmd.CommandType = CommandType.StoredProcedure

I would like to beable to get the SQL statement of "MenuItems" as a string
and use it in another part of my code... How do I do this???
EG:
Dim baseSQL As String = 'meuItems value
Dim SQL As String = baseSQL.Replace("@ParentID", "0")
..CODE...
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then

Dim Myconn As New
SqlConnection(ConfigurationSettings.AppSettings("s trConn"))
Dim cmd As New SqlCommand("MenuItems", Myconn)
cmd.CommandType = CommandType.StoredProcedure

Myconn.Open()

Dim baseSQL As String = 'meuItems value
Dim SQL As String = baseSQL.Replace("@ParentID", "0")

'OK
Dim oDataReader As SqlDataReader = cmd.ExecuteReader()
Dim oMenuItem As skmMenu.MenuItem = Nothing
Dim iOrdinal As Integer = -1
Dim myID As Long = 0
While oDataReader.Read
oMenuItem = New skmMenu.MenuItem
iOrdinal = oDataReader.GetOrdinal("Text")
oMenuItem.Text = oDataReader.GetString(iOrdinal)
iOrdinal = oDataReader.GetOrdinal("ToolTip")
oMenuItem.ToolTip = oDataReader.GetString(iOrdinal)
iOrdinal = oDataReader.GetOrdinal("Url")
oMenuItem.Url = oDataReader.GetString(iOrdinal)
iOrdinal = oDataReader.GetOrdinal("ID")
myID = Long.Parse(oDataReader.GetValue(iOrdinal).ToString )
iOrdinal = oDataReader.GetOrdinal("SubMenuItemsCount")
If oDataReader.GetInt32(iOrdinal) > 0 Then
LoadSubMenu(oMenuItem, baseSQL, myID)
End If
mnuMain.Items.Add(oMenuItem)
End While
mnuMain.CssClass = "menustyle"
mnuMain.HighlightTopMenu = True
mnuMain.Opacity = "100"
mnuMain.zIndex = 1000
mnuMain.Cursor = skmMenu.MouseCursor.Pointer

oDataReader.Close()
Myconn.Close()
End If
End Sub

Nov 19 '05 #2
No, there is no such a thing. You can use SQL Query Analyzer do modify the
sp to accommodate more parameters if you wish and can.

Eliyahu

"Tim::.." <myatix_at_hotmail.com> wrote in message
news:1B**********************************@microsof t.com...
Can someone please tell me if it is possible to get the SQL statement from a stored procedure in ASP.NET?

Dim Myconn As New SqlConnection(ConfigurationSettings.AppSettings("s trConn")) Dim cmd As New SqlCommand("MenuItems", Myconn)
cmd.CommandType = CommandType.StoredProcedure

I would like to beable to get the SQL statement of "MenuItems" as a string
and use it in another part of my code... How do I do this???
EG:
Dim baseSQL As String = 'meuItems value
Dim SQL As String = baseSQL.Replace("@ParentID", "0")
..CODE...
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then

Dim Myconn As New
SqlConnection(ConfigurationSettings.AppSettings("s trConn"))
Dim cmd As New SqlCommand("MenuItems", Myconn)
cmd.CommandType = CommandType.StoredProcedure

Myconn.Open()

Dim baseSQL As String = 'meuItems value
Dim SQL As String = baseSQL.Replace("@ParentID", "0")

'OK
Dim oDataReader As SqlDataReader = cmd.ExecuteReader()
Dim oMenuItem As skmMenu.MenuItem = Nothing
Dim iOrdinal As Integer = -1
Dim myID As Long = 0
While oDataReader.Read
oMenuItem = New skmMenu.MenuItem
iOrdinal = oDataReader.GetOrdinal("Text")
oMenuItem.Text = oDataReader.GetString(iOrdinal)
iOrdinal = oDataReader.GetOrdinal("ToolTip")
oMenuItem.ToolTip = oDataReader.GetString(iOrdinal)
iOrdinal = oDataReader.GetOrdinal("Url")
oMenuItem.Url = oDataReader.GetString(iOrdinal)
iOrdinal = oDataReader.GetOrdinal("ID")
myID = Long.Parse(oDataReader.GetValue(iOrdinal).ToString )
iOrdinal = oDataReader.GetOrdinal("SubMenuItemsCount")
If oDataReader.GetInt32(iOrdinal) > 0 Then
LoadSubMenu(oMenuItem, baseSQL, myID)
End If
mnuMain.Items.Add(oMenuItem)
End While
mnuMain.CssClass = "menustyle"
mnuMain.HighlightTopMenu = True
mnuMain.Opacity = "100"
mnuMain.zIndex = 1000
mnuMain.Cursor = skmMenu.MouseCursor.Pointer

oDataReader.Close()
Myconn.Close()
End If
End Sub

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: dinesh prasad | last post by:
I'm trying to use a servlet to process a form, then send that data to an SQL server stored procedure. I'm using the WebLogic 8 App. server. I am able to retrieve database information, so I know my...
4
by: Rhino | last post by:
Is it possible for a Java Stored Procedure in DB2 V7.2 (Windows) to pass a Throwable back to the calling program as an OUT parameter? If yes, what datatype should I use when registering the...
2
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
7
by: Dabbler | last post by:
I'm using an ObjectDataSource with a stored procedure and am getting the following error when trying to update (ExecuteNonQuery): System.Data.SqlClient.SqlException: Procedure or Function...
0
by: SOI_0152 | last post by:
Hi all! Happy New Year 2008. Il hope it will bring you love and happyness I'm new on this forum. I wrote a stored procedure on mainframe using DB2 7.1.1 and IBM language c. Everything works...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.