create procedure UpdateThing( @ThingPK int, @ThingData varchar(20) ) as declare @RowCount int; update Thing set ThingData = @ThingData where ThingPK = @ThingPK set @RowCount = @@ROWCOUNT if @RowCount = 0 begin insert into Thing (ThingPK, ThingData) values (@ThingPK,@ThingData) set @RowCount = @@ROWCOUNT end select @RowCount as Result; goand
object rowcount = this.ExecSprocScalar("UpdateThing", this.CreateParameter("@ThingPK", 4) , this.CreateParameter("@ThingData", "Hello there" )); if( ! (rowcount is int && (int)rowcount>0) ) { throw new Exception("Update failed"); }ExecNonQuery() won't call a stored procedure by name unless you build the EXEC statement by hand.