Returnvalue parameter

  • Thread starter Thread starter EdwardH
  • Start date Start date
E

EdwardH

I have Sproc:
ALTER PROCEDURE [dbo].[cPicInvent]
AS
DECLARE @retid int
BEGIN
UPDATE cConfig
SET LastInventNo = LastInventNo+1
SELECT @retid = LastInventNo FROM cConfig
RETURN @retid
END

and to pull back a new Inventory No I am using code:
Dim paret As New SqlParameter("retid", Data.SqlDbType.Int)
Using invNo = New SqlCommand("cPickInvent", invConn)
invNo.CommandType = Data.CommandType.StoredProcedure
paret.Value = "retid"
paret.Direction = Data.ParameterDirection.ReturnValue
invNo.Parameters.Add(paret)
iV = invNo.ExecuteReader
Me.txtInvNo.Text = CStr(iV(0))
iV.Close()
End Using

I am getting message
"Connection has not been initialised"
Any pointers gratefully received.
 
I have Sproc:
ALTER PROCEDURE [dbo].[cPicInvent]
AS
DECLARE @retid int
BEGIN
UPDATE cConfig
SET LastInventNo = LastInventNo+1
SELECT @retid = LastInventNo FROM cConfig
RETURN @retid
END

and to pull back a new Inventory No I am using code:
Dim paret As New SqlParameter("retid", Data.SqlDbType.Int)
Using invNo = New SqlCommand("cPickInvent", invConn)
invNo.CommandType = Data.CommandType.StoredProcedure
paret.Value = "retid"
paret.Direction = Data.ParameterDirection.ReturnValue
invNo.Parameters.Add(paret)
iV = invNo.ExecuteReader
Me.txtInvNo.Text = CStr(iV(0))
iV.Close()
End Using

I am getting message
"Connection has not been initialised"
Any pointers gratefully received.

You don't seem t have initialized the invConn object. Perhas the problem
lies there
 
Rad,

You cannot initialize an inv(alid)Conn(ection)

:-)

I know that it is probably inventory

For the OP


2008
Dim invlConn = new SqlConnection(connectionString)

2008 and older
Dim invlConn as new SqlConnection(connectionString)

www.connectionStrings.Com

Cor


Rad said:
I have Sproc:
ALTER PROCEDURE [dbo].[cPicInvent]
AS
DECLARE @retid int
BEGIN
UPDATE cConfig
SET LastInventNo = LastInventNo+1
SELECT @retid = LastInventNo FROM cConfig
RETURN @retid
END

and to pull back a new Inventory No I am using code:
Dim paret As New SqlParameter("retid", Data.SqlDbType.Int)
Using invNo = New SqlCommand("cPickInvent", invConn)
invNo.CommandType = Data.CommandType.StoredProcedure
paret.Value = "retid"
paret.Direction = Data.ParameterDirection.ReturnValue
invNo.Parameters.Add(paret)
iV = invNo.ExecuteReader
Me.txtInvNo.Text = CStr(iV(0))
iV.Close()
End Using

I am getting message
"Connection has not been initialised"
Any pointers gratefully received.

You don't seem t have initialized the invConn object. Perhas the problem
lies there
 
Back
Top