By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,928 Members | 1,173 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,928 IT Pros & Developers. It's quick & easy.

Get output parameter sqlclient stored procedure

P: n/a
Ben
Hi

I have the code below which i got from:

It only appers to return 1 from the stored procedure, where as the figure
should be 43253

Any help with a solution would be much appreciated,

Thanks
B

'Calling Function
Dim Parameters(0) As SqlParameter

Parameters(0) = New SqlParameter("@iReturn", SqlDbType.Int) :
Parameters(0).Value = 0

intCaseItem_No = SqlDataProvider.ExecuteQuery(strConnectionString,
"sp_GetClientID", CommandType.StoredProcedure, Parameters)

'Function

Public Shared Function ExecuteQuery(ByVal ConnectionString As String, ByVal
CommandText As String, ByVal CommandType As CommandType, _

ByVal CommandParameters() As SqlParameter) As Object

Dim ReturnValue As Object = Nothing

Try

SqlConn = New SqlConnection(ConnectionString)

SqlComm = New SqlCommand(CommandText, SqlConn)

SqlComm.CommandType = CommandType

Dim OutputParameter As String = SqlDataProvider.AddParameters(SqlComm,
CommandParameters)

If Not (SqlConn.State = ConnectionState.Open) Then SqlConn.Open()

ReturnValue = SqlComm.ExecuteNonQuery()

If Not (OutputParameter = String.Empty) Or OutputParameter <> "" Or
CommandType = CommandType.StoredProcedure Then

ReturnValue = SqlComm.Parameters(0).Value.ToString()

End If

Catch ex As Exception

_LastError = ex

Finally

If Not (SqlConn.State = ConnectionState.Closed) Then SqlConn.Close()

End Try

Return ReturnValue

End Function
Apr 1 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.