Retrieve return value of SQL User Defined Function?

M

Mark B

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?
 
M

Munna

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
 
S

siccolo

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top