I have a stored procedure where I do INSERT
, and then RAISERROR("MyException", 5, 5)
, in this case, the insertion fails.
The problem is that the result for my .NET application is
MyException: cannot insert null value ...
Thus, it returns 2 exceptions in one.
My .NET code always just matched the entire string with "MyException", but that no longer works.
Is this standard? And if so, how could this work before? Are there any settings for this?
edit:
I am using a .NET table adapter to work with an SQL database.
Version
Product: Microsoft SQL Server Enterprice (64-bit) Version: 11.0.2100.60 Cluster: False HADR: False
Microsoft Framework .NET 4.6.2
Stored procedure
ALTER Procedure [dbo].[up_kod_text_save]
@entity_id int,
@text varchar(300),
@kod_key int,
@kod_id int,
@korttext varchar(10),
@inaktiv bit,
@primar_extern_kod varchar(300),
@sparad_av varchar(128),
@kod_typ_id int,
@kod varchar(20),
@original_rowver rowversion,
@associerat_varde decimal(18,5),
@beskrivning varchar(2000),
@viktigt_varde bit
AS
BEGIN
SET NOCOUNT ON;
DECLARE @resultat table(kod_id int, uppdat_tidpunkt datetime, rowver binary(8) );
Insert into @resultat
exec up_kod_save @kod_id,@text,@korttext,@inaktiv,@primar_extern_kod,@sparad_av,@kod_typ_id,@kod,@original_rowver, @associerat_varde, @beskrivning,@viktigt_varde
declare @uppdat_tidpunkt datetime
declare @rowver rowversion
declare @tablename varchar(30)
declare @idname varchar(30)
SET @rowver = (SELECT rowver FROM @resultat)
SET @kod_id = (SELECT kod_id from @resultat)
set @uppdat_tidpunkt = getdate()
IF(@kod_key = 2)
BEGIN
ELSE IF(@kod_key = 11)
BEGIN
IF EXISTS ( SELECT akut_checklista_id FROM akut_checklista WHERE akut_checklista_id = @entity_id )
BEGIN
UPDATE akut_checklista
SET [text] = @text,
[kod_id] = @kod_id
WHERE akut_checklista_id = @entity_id
END
ELSE
BEGIN
INSERT INTO [akut_checklista] ([text], [kod_id])
VALUES (@text, @kod_id);
set @entity_id = SCOPE_IDENTITY()
END
END
ELSE
BEGIN
RAISERROR ('MyApp_EXCEPTION_UPPDATERAD_AV_ANNAN',16,1)
RETURN
END
SELECT @entity_id as entity_id, @rowver as rowver, @kod_id as kod_id, @uppdat_tidpunkt as uppdat_tidpunkt
Up_kod_save \ - . , rowversion .