c# - SQL returning DBnull instead of integer -
i'm trying add record table, , when record exists, want return -3. in c# code, sql server returns dbnull
. not sure why, because returns scope_identity
no problem. here sql, appreciated.
alter procedure [dbo].[inserttype] @name varchar(20), @username varchar(12), @returnid int output begin -- set nocount on added prevent result sets -- interfering select statements. set nocount on; if exists (select name tbltypes username = @username , name = @name) begin return -3 --already exists end else begin insert tbltypes (name, username) values (@name, @username) set @returnid = scope_identity() return @returnid end end
Comments
Post a Comment