Executing Stored Procedure from ASP.net

Posted on 2006-04-12
Medium Priority
Last Modified: 2011-09-20

I have get_sales stored procedure which is working absolutely fine when org_id,sales_limit are passed from the query analyzer. Now from the asp.net page I have this function to get the sales.

from my page I am trying to execute this function

Private Function getNewSales(ByVal sales_limit As Double) As Double
getSales(Session.Item("BB").ToString, sales_limit, 0)

Return getNewSales

End Function

But I am not getting the value. Please help.

Public Function getSales(ByVal _org_id As String, ByVal sales_limit As Double, ByRef _FF As Double) As Boolean

            Dim cmd As New System.Data.SqlClient.SqlCommand
            cmd.CommandText = "dbo.[get_sales]"
            cmd.CommandType = System.Data.CommandType.StoredProcedure
            cmd.Connection = sql_connection
            cmd.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4,    System.Data.ParameterDirection.ReturnValue, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
            cmd.Parameters.Add(New System.Data.SqlClient.SqlParameter("@org_id", System.Data.SqlDbType.VarChar, 10))
            cmd.Parameters.Add(New System.Data.SqlClient.SqlParameter("@sales_limit", System.Data.SqlDbType.Float, 8))
            cmd.Parameters.Add(New System.Data.SqlClient.SqlParameter("@FF", System.Data.SqlDbType.Float, 8, System.Data.ParameterDirection.Output, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))

            cmd.Parameters("@franchise_id").Value = _org_id
            cmd.Parameters("@sales_limit").Value = sales_limit


            Dim reader As SqlDataReader = cmd.ExecuteReader()

            If reader.Read() Then
                _ff = Convert.ToDouble(reader("ff"))
                _f = 0

            End If

            If CInt(cmd.Parameters("@RETURN_VALUE").Value) = 0 Then
                Return True
                Return False
            End If

        End Function
Question by:sureshraina
LVL 14

Accepted Solution

existenz2 earned 2000 total points
ID: 16436099
            If CInt(cmd.Parameters("@RETURN_VALUE").Value) = 0 Then
                Return True
                Return False
            End If

            Dim success AS System.Boolean
            If CInt(cmd.Parameters("@RETURN_VALUE").Value) = 0 Then
                success = True
                success  = False
            End If
            return success

Expert Comment

ID: 16436358
how are you returning the value from your stored proc.... if you are using a return 0, it may not work.. use SELECT 0... just a point to check..

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Free Data Recovery software is an advanced solution from Kernel Tools to recover data and files such as documents, emails, database, media and pictures, etc. It supports recovery from physical & logical drive after a hard disk crash, accidental/inte…
To export Lotus Notes to Outlook PST or Exchange and Domino Server files to Exchange Server or PST files with ease, go for Kernel for Lotus Notes to Outlook conversion tool. Through the video, you can watch the conversion process. A common user with…

619 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