INSERT語句與CHECK約束「ck_str_member_no
」衝突。衝突發生在數據庫「C:\ DOCUMENTS AND SETTINGS \ KARTHIKEYAN \ DESKTOP \ KOK \ DB \ INFT3009_ASS1_C3104855.MDF」,表「dbo.Members」,列'str_member_no
'。 該聲明已被終止。SQL服務器錯誤:INSERT語句與CHECK約束衝突
我在Visual Studio 2008 Express中使用.MDF文件。我如何解決它?
我的插入過程:
ALTER PROCEDURE [dbo].[AddNewAGCMember]
-- Add the parameters for the stored procedure here
@str_member_no varchar(6) = '',
@str_member_name varchar(50) = '',
@str_member_password varchar(10) = '',
@str_addr_apartment_no varchar(10) = NULL,
@str_addr_building_name varchar(50) = NULL,
@str_addr_street_name varchar(50) = NULL,
@int_postal_code int = NULL,
@str_country_name varchar(50) = NULL,
@int_contact_no int = NULL,
@str_email_addr varchar(100) = '',
@date_registration date = ''
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
INSERT INTO Members
(str_member_no,
str_member_name,
str_member_password,
str_addr_apartment_no,
str_addr_building_name,
str_addr_street_name,
int_postal_code,
str_country_name,
int_contact_no,
str_email_addr,
date_registration)
VALUES
(@str_member_no,
@str_member_name,
@str_member_password,
@str_addr_apartment_no,
@str_addr_building_name,
@str_addr_street_name,
@int_postal_code,
@str_country_name,
@int_contact_no,
@str_email_addr,
@date_registration);
END
表結構:
str_member_no
,VARCHAR(6),未檢查str_member_name
,VARCHAR(50),未檢查str_member_password
,VARCHAR(10),未檢查str_addr_apartment_no
,VARCHAR(10),經過str_addr_building_name
,VARCHAR(50),經過str_addr_street_name
,VARCHAR(50),經過int_postal_code
,INT,經過str_country_name
,VARCHAR(50),經過int_contact_no
,整型,經過str_email_addr
,VARCHAR(100),未選中date_registration
,日期,未選中Unchecked
請把你創建表的腳本和Insert語句還那麼它將更容易理解.. – 2009-09-30 04:00:01
你是否應用了像str_member_no的唯一主鍵? – 2009-09-30 04:15:16