How to get @Return_Value parameter? It is not generated in TableAdapter.Fill

K

Karel Kral

Hello,
I am using strongly typed dataset. I am calling stored proc and I want
to get return value from SP. So I have created SP Test (see bellow). I
have added TableAdapter for this procedure.

But how to get @Return_Value from this procedure? I have seen generated
code for TableAdapter.Fill and @Return_Value parameter is simply ignored.

CREATE PROCEDURE Test
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
return 1
END


<System.Diagnostics.DebuggerNonUserCodeAttribute()> _
Private Sub InitCommandCollection()
Me._commandCollection = New
System.Data.SqlClient.SqlCommand(0) {}
Me._commandCollection(0) = New System.Data.SqlClient.SqlCommand
Me._commandCollection(0).Connection = Me.Connection
Me._commandCollection(0).CommandText = "dba.Test"
Me._commandCollection(0).CommandType =
System.Data.CommandType.StoredProcedure
Me._commandCollection(0).Parameters.Add(New
System.Data.SqlClient.SqlParameter("@RETURN_VALUE",
System.Data.SqlDbType.Int, 4,
System.Data.ParameterDirection.ReturnValue, 10, 0, Nothing,
System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
End Sub

<System.Diagnostics.DebuggerNonUserCodeAttribute(), _

System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter"),
_

System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Fill,
true)> _
Public Overloads Overridable Function Fill(ByVal dataTable As
dsProdej.TestDataTable) As Integer
Me.Adapter.SelectCommand = Me.CommandCollection(0)
If (Me.ClearBeforeFill = true) Then
dataTable.Clear
End If
Dim returnValue As Integer = Me.Adapter.Fill(dataTable)
Return returnValue
End Function
End Class
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top