sql不替换uid的更新数据语句

1.覆盖数据时uid主键不修改的语句

on duplicate key update

private void ImportMyData(string name,string year,List<MyInfoDetail> listMyInfo)
{
 IDbShell shell_w = Common.GetIDbShell(ActionType.Read);
try
{
shell_w.BeginTransaction();
if(listMyInfo!=NULL &&listMyInfo.Count>0)
{
foreach (var exeein listMyInfo)
{     
string Uid=exee.ex_id+exee.exam_no+exee.es_num;
string sql = @"insert into `userinfo` VALUES(@0,@1,@2,@3,@4,@5,@6,'A',@7,@8,@9,@10,@11,@12,@13,@14,@15,@16,now(),now())
 on duplicate key update  id=@1,num=@2,no=@3,name=@4,cert_id=@5,cert_no=@6,code=@7,lxdm=@8,cldm=@9,ssdm=@10, ss=@11,                                      cl=@12,bj=@13,mc=@14,qk=@15,sj=@16,update_time=now(),create_time=now();";
shell_w.ExecuteQueryDataSet(sql, Uid, Id, num, no, name, cert_id, cert_no,code, exee.wglxdm, cldm, ssdm, ss, cl, bj,mc, qk, sj);                     }
}
}
shell_w.Commit();
}
catch(Exception ex)
{
 shell_w.Rollback();
  Common.SaveErrorLog(ex.Message);
  shell_w.EndTransaction();      
}
  finally
   {
                shell_w.Close();
                shell_w.Dispose();
            }
}

猜你喜欢

转载自my.oschina.net/u/3544533/blog/1788724