我得到的错误是:
错误号码:23000/544
[Microsoft] [SQL Server Native Client 11.0] [SQL Server]无法插入 表'audit_domain'中的标识列的显式值 IDENTITY_INSERT设置为OFF。
UPDATE "domain" SET "domain_acronym" = 'RM', "domain" = Resource Management', "reference_name" = 'Resource Mgmt' WHERE "id" = '1'
我正在使用的代码:
$updatedata['domain_acronym'] = $this->postdata['domain_acronym'];
$updatedata['domain_name'] = $this->postdata['domain_name'];
$updatedata['reference_name'] = $this->postdata['reference_name'];
$this->db->where($pk, $pkValue);
$this->db->update('domains', $updatedata);
域表具有Id的主键,审计表没有任何主键集。我一直试图解决这个问题几天,所以任何关于如何调试/修复它的指针都会非常感激。
答案 0 :(得分:0)
运行此查询
SET IDENTITY_INSERT YourtableName ON
答案 1 :(得分:0)
尝试这种方式
$domain_acronym = $this->postdata['domain_acronym'];
$domain_name = $this->postdata['domain_name'];
$reference_name = $this->postdata['reference_name'];
$query="update table_name set col_name1='$domain_acronym',col_name2='$domain_name ',col_name3='$reference_name ' where id=$pkValue";
$this-db->query($query);