Click to See Complete Forum and Search --> : sqlDataSource parameter


rbruch
02-21-2007, 04:53 AM
Hi, question about asp.net

have a sqlDataSource with insert command :

'INSERT INTO [usuaris] ([nomcomplert], [usuari]) VALUES (@NOMCOMPLERT, @USUARI);
SELECT @INSERT_ID = IDENT_CURRENT('usuaris') '

How can I retrieve the @INSERT_ID value? No 'Value' property for sqlDataSource.InsertParamenters("INSERT_ID"), only 'DefaultValue' is avalaible.

@INSERT_ID is in output (or ReturnValue) mode.

Ribeyed
02-21-2007, 06:50 AM
Hi,
in your stored procedure add the following:

RETURN @@Identity

Then in your code add this:

parm = myCommand.Parameters.Add("ReturnValue", SqlDbType.Int)
parm.Direction = ParameterDirection.ReturnValue