Executing Stored Procedure from

Posted on 2006-04-12
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 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

                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
    LVL 3

    Expert Comment

    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

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Suggested Solutions

    In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    728 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now