G
Guest
Hello All!
I'm calling a store proc in my vb.net code, but the value returned is
always 0, which is wrong. But when I runt the query in SQL, it's working
fine. My SP is
CREATE PROCEDURE [dbo].[max tableid] AS
SELECT MAX(TableID) AS returnvalue
FROM TableID
WHERE (Inuse =1)
GO
and my code is
cmdLog = New SqlCommand("Max TableID", conLog)
cmdLog.CommandType = CommandType.StoredProcedure
TableIDReturn = cmdLog.Parameters.Add("ReturnValue", SqlDbType.Int)
TableIDReturn.Direction = ParameterDirection.ReturnValue
conLog.Open()
cmdLog.ExecuteNonQuery()
intTableID = cmdLog.Parameters("ReturnValue").Value
txtTableid.Text = intTableID.ToString()
If intTableID <= 5 Then
myMainfrm.Show()
Else : intTableID = 0
MessageBox.Show("Sorry")
conLog.Close()
End If
I have the string in there to see what the value is returned.
Any thoughts what I'm doing wrong?
Thanks!!
Rudy
I'm calling a store proc in my vb.net code, but the value returned is
always 0, which is wrong. But when I runt the query in SQL, it's working
fine. My SP is
CREATE PROCEDURE [dbo].[max tableid] AS
SELECT MAX(TableID) AS returnvalue
FROM TableID
WHERE (Inuse =1)
GO
and my code is
cmdLog = New SqlCommand("Max TableID", conLog)
cmdLog.CommandType = CommandType.StoredProcedure
TableIDReturn = cmdLog.Parameters.Add("ReturnValue", SqlDbType.Int)
TableIDReturn.Direction = ParameterDirection.ReturnValue
conLog.Open()
cmdLog.ExecuteNonQuery()
intTableID = cmdLog.Parameters("ReturnValue").Value
txtTableid.Text = intTableID.ToString()
If intTableID <= 5 Then
myMainfrm.Show()
Else : intTableID = 0
MessageBox.Show("Sorry")
conLog.Close()
End If
I have the string in there to see what the value is returned.
Any thoughts what I'm doing wrong?
Thanks!!
Rudy