I'm trying to call the following SP (on a SQL 2000 database

CREATE PROCEDURE fsp_NextSequenceCd

@Entity as varchar(50)
@Sequence as varchar(50) OUTPU

A
[...

Which basically retreive the next sequence ID for the specified Entity. It works fine when called in VB6 or in SQL Query Analyser

However, the following VB.Net code will not work (An empty string is always returned in the Output parameter)

Public Function GetNextSequence(ByVal Type As enSequenceType) As Strin
Dim Command As New SqlClient.SqlComman

Command.Connection = mConnectio
Command.CommandType = CommandType.StoredProcedur
Command.CommandText = Me.CST_SP_NEXT_SEQ_C

Dim NewParam = New SqlClient.SqlParamete

NewParam.Direction = ParameterDirection.Inpu
NewParam.ParameterName = "@Entity
NewParam.SqlDbType = SqlDbType.VarCha
NewParam.value = "LOT

Command.Parameters.Add(NewParam

NewParam = New SqlClient.SqlParamete

NewParam.Direction = ParameterDirection.Outpu
NewParam.ParameterName = "@Sequence
NewParam.SqlDbType = SqlDbType.VarCha
NewParam.value = System.Data.SqlTypes.SqlString.Nul

Command.Parameters.Add(NewParam

Command.ExecuteNonQuery(

Return Command.Parameters.Item("@Sequence").Valu
End Functio

Re: Output parameter not fed by Wes

Wes
Fri Feb 20 12:33:41 CST 2004

Alex,

Your VB.Net code looks correct. Is the @Sequence parameter being SET
somewhere in the Stored Procedure?

Wes

On Fri, 20 Feb 2004 07:31:05 -0800, Alex <a_fafard@hotmail.com> wrote:

> I'm trying to call the following SP (on a SQL 2000 database)
>
> CREATE PROCEDURE fsp_NextSequenceCd
>
> @Entity as varchar(50),
> @Sequence as varchar(50) OUTPUT
>
> AS
> [...]
>
> Which basically retreive the next sequence ID for the specified Entity.
> It works fine when called in VB6 or in SQL Query Analyser.
>
> However, the following VB.Net code will not work (An empty string is
> always returned in the Output parameter) :
>
> Public Function GetNextSequence(ByVal Type As enSequenceType) As
> String
> Dim Command As New SqlClient.SqlCommand
>
> Command.Connection = mConnection
> Command.CommandType = CommandType.StoredProcedure
> Command.CommandText = Me.CST_SP_NEXT_SEQ_CD
>
> Dim NewParam = New SqlClient.SqlParameter
>
> NewParam.Direction = ParameterDirection.Input
> NewParam.ParameterName = "@Entity"
> NewParam.SqlDbType = SqlDbType.VarChar
> NewParam.value = "LOT"
>
> Command.Parameters.Add(NewParam)
>
> NewParam = New SqlClient.SqlParameter
>
> NewParam.Direction = ParameterDirection.Output
> NewParam.ParameterName = "@Sequence"
> NewParam.SqlDbType = SqlDbType.VarChar
> NewParam.value = System.Data.SqlTypes.SqlString.Null
>
> Command.Parameters.Add(NewParam)
>
> Command.ExecuteNonQuery()
>
> Return Command.Parameters.Item("@Sequence").Value
> End Function
>