请尽早提供帮助 [英] Pls help as early as possible

查看:73
本文介绍了请尽早提供帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我在通过存储过程插入数据时会出现此错误.这里有什么问题
错误:The INSERT statement conflicted with the CHECK constraint "CK__Master_Adm__role__7E6CC920". The conflict occurred in database "samp", table "dbo.Master_Admin", column ''role''.

我有桌子,桌子的结构就像

Why Iam getting this error while iam inserting data through stored procedure. Any thing is wrong here
Error:The INSERT statement conflicted with the CHECK constraint "CK__Master_Adm__role__7E6CC920". The conflict occurred in database "samp", table "dbo.Master_Admin", column ''role''.

I have table, the table structure is like

CREATE TABLE Master_Admin
(
mstr_id int primary key identity(1,1),
login_UserName varchar(30) not null unique,
login_pass varchar(20) not null,
role char(20) check(role in (''SuperAdmin'',''Admin'',''EndUser'')) not null,
)


通过存储过程和SP的结构,IAM将值插入到此表中就像


And iam inserting values into this table through storedprocedure and structure of SP is like

create procedure Master_Admin_Insert(
@login_uname varchar(30),
@login_pwd varchar(20),
@role char(20)
)
as
begin
insert into Master_Admin(
login_UserName,
login_pass,
role
)
values
(
''@login_uname'',
''@login_pwd'',
''@role''
)
end


程序执行


Execution of Procedure

declare @login_uname varchar(30),
@login_pwd varchar(20),
@role char(20)
set @login_uname=''sai''
set @login_pwd=''sai123''
set @role=''EndUser''
exec Master_Admin_Insert @login_uname,@login_pwd,@role

推荐答案

删除Insert语句的值列表中的单引号.试试这个
Remove the single quotes in the value list of your Insert statement. Try this
insert into Master_Admin(
login_UserName,
login_pass,
role
)
values
(
@login_uname,
@login_pwd,
@role
)


这篇关于请尽早提供帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆