62,046
社区成员
发帖
与我相关
我的任务
分享
Student s = new Student();
{
s.Sname = "学生7";
s.Ssex = 1;
s.Sage = 23;
};
datacontext.Student.InsertOnSubmit(s);
datacontext.SubmitChanges();//报错:当 IDENTITY_INSERT 设置为 OFF 时,不能向表 'Student' 中的标识列插入显式值。
set identity_insert tablename on
insert tablename(id) select 11
select * from tablename
go
--set identity_insert tablename off
drop table tablename
/*
id
----
1
11
*/
set identity_insert tablename on
Student s = new Student();
{
//sSid="11";其中Sid为主键,自增
s.Sname = "学生7";
s.Ssex = 1;
s.Sage = 23;
};
datacontext.Student.InsertOnSubmit(s);
datacontext.SubmitChanges();//报错:当 IDENTITY_INSERT 设置为 OFF 时,不能向表 'Student' 中的标识列插入显式值