Erreur: Cannot insert the value NULL
Salut,
J'ai cree une table pour mettre mes articles en categories.
Code:
1 2 3 4 5 6 7 8
| Column Name
CategoryID int - PK
AddedDate
AddedBy
Title
Importance
Description
ImageUrl |
La procedure pour l'insertion de categories:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| ALTER PROCEDURE dbo.RA_Articles_InsertCategory
(
@AddedDate datetime,
@AddedBy nvarchar(256),
@Title nvarchar(256),
@Importance int,
@Description nvarchar(4000),
@ImageUrl nvarchar(256),
@CategoryID int OUTPUT
)
AS
SET NOCOUNT ON
-- check whether a category with the same name already exists
DECLARE @CurrID int
SELECT @CurrID = CategoryID FROM RA_Categories WHERE
LOWER(@Title) = LOWER(Title)
IF @CurrID IS NOT NULL
BEGIN
SET @CategoryID = -1
RETURN
END
INSERT INTO RA_Categories
(AddedDate, AddedBy, Title, Importance, Description, ImageUrl)
VALUES (@AddedDate, @AddedBy, @Title, @Importance, @Description, @ImageUrl)
SET @CategoryID = scope_identity() |
J'obtients l'erreur suivante lots de l'insertion d'une nouvelle categorie:
Code:
1 2
| Cannot insert the value NULL into column 'CategoryID', table 'C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR\MY DOCUMENTS\VISUAL STUDIO 2005\WEBSITES\SENIORPROJECT\APP_DATA\ASPNETDB.MDF.dbo.RA_Categories'; column does not allow nulls. INSERT fails.
The statement has been terminated. |
Je vous prie de m'aider :(