468,512 Members | 1,560 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

Retrieve return value of SQL User Defined Function?

I have been able to retrieve the scalar value of a SQL Server Stored
Procedure as follows:

Shared Function fGetGroupPerformanceStatistic(ByVal strGroup As String) As
String

Dim sqlConnection1 As New SqlConnection("Data
Source=MARK\SQLEXPRESS;Initial Catalog=GroupSales;Integrated
Security=True;")
Dim cmd As New SqlCommand

cmd.CommandText = "ufWebStatsAverageSalesGroup"
cmd.CommandType = Data.CommandType.StoredProcedure
cmd.Connection = sqlConnection1
sqlConnection1.Open()
cmd.Parameters.Add(New SqlParameter("@EnterGroup", strGroup))
fGetGroupPerformanceStatistic = cmd.ExecuteScalar()
sqlConnection1.Close()

End Function
Now I want to retrieve the value from an SQL Server User Defined Function
udf.GetTopSalesFigure(@EnterGroup nvarchar(50))

How would I do that in VB code similar to the code above?

Also, can I do it by just dragging an SQLDataSource control onto the aspx
page and referencing that?




Jun 27 '08 #1
2 2405
On Jun 9, 11:42 am, "Mark B" <n...@none.comwrote:
I have been able to retrieve the scalar value of a SQL Server Stored
Procedure as follows:

Shared Function fGetGroupPerformanceStatistic(ByVal strGroup As String) As
String

Dim sqlConnection1 As New SqlConnection("Data
Source=MARK\SQLEXPRESS;Initial Catalog=GroupSales;Integrated
Security=True;")
Dim cmd As New SqlCommand

cmd.CommandText = "ufWebStatsAverageSalesGroup"
cmd.CommandType = Data.CommandType.StoredProcedure
cmd.Connection = sqlConnection1
sqlConnection1.Open()
cmd.Parameters.Add(New SqlParameter("@EnterGroup", strGroup))
fGetGroupPerformanceStatistic = cmd.ExecuteScalar()
sqlConnection1.Close()

End Function

Now I want to retrieve the value from an SQL Server User Defined Function
udf.GetTopSalesFigure(@EnterGroup nvarchar(50))

How would I do that in VB code similar to the code above?

Also, can I do it by just dragging an SQLDataSource control onto the aspx
page and referencing that?
Hi

follow this thread...

http://forums.devx.com/showthread.php?t=146418

call function in store procedure call the store procedure from asp.net

Best of luck

Munna
www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com
Jun 27 '08 #2
if you have a function GetTopSalesFigure(<some paremeters>), then in
your stored proc

create stored procedure fGetGroupPerformanceStatistic
(
....your parameters...
)
as
select dbo. GetTopSalesFigure(<some paremeters>) as
test_function_result

.... more articles at http://www.siccolo.com/articles.asp
Jun 27 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by forums_mp | last post: by
18 posts views Thread by Pedro Pinto | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.