Hey -
Some help would be greatly appreciated.
Probably a simple one for you guys…
I am trying to return the highest value for a claim_id in a database. I have the following stored procedure:
ALTER PROCEDURE [dbo].[getLastAddedRec]
-- Add the parameters for the stored procedure here
@lastAdded INT out
AS
SET NOCOUNT ON
SET @lastAdded =
(SELECT MAX(claimant_id_int) AS added FROM claimant)
This brings back the highest value as added and I thought the variable @lastadded would be set as the highest value.
I am calling this SP with this code:
'Setup connection to database
Dim myConnection As New Data.SqlClient.SqlConnection(Me.SqlDataSource1.ConnectionString)
myConnection.Open()
'Setup SQLCommand for SELECT statement from SQLDataSource1
Dim myCommand As New Data.SqlClient.SqlCommand("getLastAddedRec", myConnection)
myCommand.CommandType = Data.CommandType.StoredProcedure
myCommand.Parameters.Clear()
'Create a SqlParameter object to hold the output parameter value
Dim retValParam As New Data.SqlClient.SqlParameter("@lastAdded", Data.SqlDbType.Int)
'Set Direction as ReturnValue
retValParam.Direction = Data.ParameterDirection.ReturnValue
'Add the parameter to the Command's Parameters collection
myCommand.Parameters.Add(retValParam)
'Execute the command
myCommand.ExecuteNonQuery()
myConnection.Close()
Response.Write(retValParam)
However retValParam is returning “@lastadded”
Can anyone give me a few pointers as to how I can get a number into @lastadded?
Many thanks.
DS