This is a migrated thread and some comments may be shown as answers.

[Solved] @return_value from ado.net

0 Answers 161 Views
Grid
This is a migrated thread and some comments may be shown as answers.
L
Top achievements
Rank 1
L asked on 17 Nov 2009, 02:44 AM
hi

I know this is not a proper place to post my thread.Am sorry.

I have this code and i am not to get the retun value from the proc. I did a breakpoint on the function and the invoice variable is empty.

What is worng with this code? Thanks

ALTER PROCEDURE [dbo].[spGetName]
@prodID as nvarchar(50)
AS
BEGIN
Declare @invoiceID as Nvarchar(50)
Set @invoiceID = Replace(replace(Replace(replace(CONVERT(Nvarchar(50),Getdate(),120),'-',''),' ' ,''),':',''),'.','')
Insert into dbo.Invoice(invoiceID,ProdID) values(@invoiceID,@prodID)
Return @invoiceID
END



 Shared Function Invoice(ByVal prodID As String) As String
        Dim Invoice As String
        Using sqlcmd As New SqlCommand("spGetName", getConn)
            sqlcmd.CommandType = Data.CommandType.StoredProcedure
            sqlcmd.Parameters.Add(New SqlParameter("@prodID", SqlDbType.NVarChar, 50)).Value = prodID 
            Invoice = sqlcmd.Parameters.Add(New SqlParameter("@Return_Value", SqlDbType.NVarChar, 50)).Direction = ParameterDirection.ReturnValue
     sqlcmd.ExecuteNonQuery()       
 End Using
        getConn.Close()
        Return Invoice
    End Function

 

No answers yet. Maybe you can help?

Tags
Grid
Asked by
L
Top achievements
Rank 1
Share this question
or