Executing Stored Procedure from ASP.net

Hello,

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


            sql_connection.Open()

            Dim reader As SqlDataReader = cmd.ExecuteReader()

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


            End If
            sql_connection.Close()

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


        End Function
sureshrainaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

existenz2Commented:
Change:
            sql_connection.Close()
   
            If CInt(cmd.Parameters("@RETURN_VALUE").Value) = 0 Then
                Return True
            Else
                Return False
            End If

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
prajeebkumarCommented:
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..
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.