472,958 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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 2592
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: forums_mp | last post by:
I've got an STL class (see below) with two functions to store and retrieve data - msg structs. The "Store" function when called will copy the received message (depending on which message) into...
0
by: Manesh | last post by:
I have an oracle function which return an oracle user defined table type. How to retrieve values from this type (function from a vb.net application ? Here is my sample code Please help create or...
0
by: george_Martinho | last post by:
It seems that the ASP.NET Microsoft team didn't think about this!! The profilemanager class has the following methods: - DeleteInactiveProfiles. Enables you to delete all profiles older than a...
4
by: serge | last post by:
http://www.csharphelp.com/archives2/archive342.html I am using the sample code from this link but I am unable to figure out how to retrieve the list of the User-Defined Functions. I am able to...
18
by: Pedro Pinto | last post by:
Hi there once more........ Instead of showing all the code my problem is simple. I've tried to create this function: char temp(char *string){ alterString(string); return string;
10
by: Raj | last post by:
I need a VB function to return array of collections like Private Type Employee empname as string address as string salary as integer deptno as integer End Type dim employees() as Employee
4
by: kang jia | last post by:
hi i am doing mailinglist currently. the code in my first page is like this : : <html> <head> <link rel="stylesheet" type="text/css" href="gallery.css" /> <script language="JavaScript"> ...
4
chumlyumly
by: chumlyumly | last post by:
Hi - I'm working with PHP5 MySQL Mac OSX I've developed two pages where a user can input his/her info, which goes to a MySQL database. The first page is supposed to pass the newly created...
1
maxamis4
by: maxamis4 | last post by:
Hello folks, Here is the backgroup. I am creating an agent that can find a user in LDAP and return the last logon date. Now i am not sure if with active directory you can user the...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.