日期:2014-05-17 浏览次数:20732 次
当 IDENTITY_INSERT 设置为 OFF 时,不能为表 'bx_wap_TypeInfo' 中的标识列插入显式值。 说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.SqlClient.SqlException: 当 IDENTITY_INSERT 设置为 OFF 时,不能为表 'bx_wap_TypeInfo' 中的标识列插入显式值。 源错误: 行 54: ti.memo = memo.Text.Trim(); 行 55: table.InsertOnSubmit(ti); 行 56: dc.SubmitChanges(); 行 57: string CacheName = SiteConfig.PrefixName + dc.Mapping.GetTable(typeof(bx_wap_TypeInfo)).TableName; 行 58: IXinHuaCache cache = XinHuaCache.Instance();
DataContext dc = DataContextHelper.DataContext; Table<bx_wap_TypeInfo> table = dc.GetTable<bx_wap_TypeInfo>(); bx_wap_TypeInfo ti = new bx_wap_TypeInfo(); // ti.typeid = 0;typeid是主键未赋值 ti.typename = tbstypename.Text.Trim(); ti.typeimg = fileName; ti.status = 0; ti.cpid = 1; ti.parentid =0; ti.ctype =1; ti.sortid = 0; ti.memo = memo.Text.Trim(); table.InsertOnSubmit(ti); dc.SubmitChanges(); dc.Dispose();
[Table(Name = "bx_wap_TypeInfo")] public partial class bx_wap_TypeInfo : ModelBase { public bx_wap_TypeInfo() { //base.M_TableName = "bx_wap_TypeInfo"; } #region Model private int _typeid; private string _typename; private string _typeimg; private int? _status = 0; private int? _cpid = 0; private int? _parentid = 0; private int? _ctype = 0; private int? _sortid = 0; private string _memo; private DateTime? _addtime = DateTime.Now; private int? _totalvideo = 0; private int? _delstatus = 0; /// <summary> /// /// </summary> [Column(IsPrimaryKey = true)] public int typeid { set { _typeid = value;// base.M_PrimaryKeyID = value; } get { return _typeid; } } [Column(Name = "typename")] public string typename { set { _typename = value; } get { return _typename; } } [Column(Name = "typeimg")] public string typeimg { set { _typeimg = value; } get { return _typeimg; } } [Column(Name = "status")] public int? status { set { _status = value; } get { return _status; } } [Column(Name = "cpid")] public int? cpid { set { _cpid = value; } get { return _cpid; } } [Column(Name = "parentid")] public int? parentid { set { _parentid = value; } get { return _parentid; } } [Column(Name = "ctype")] public int? ctype { set { _ctype = value; } get { return _ctype; } } [Column(Name = "sortid")] public int? sortid { set { _sortid = value; } get { return _sortid; } } [Column(Name = "memo")] public string