SqlCommandBuilder产生的UpdateCommand莫名其妙
高手指点,只有10分,代码如下:
myBuild.DataAdapter = da;
comm.CommandText = "SELECT ID_DEPT,ID_PARA,NO_DEPT,NM_DEPT FROM BS_DEPT "; //ID_DEPT是主键
da.SelectCommand = comm;
da.UpdateCommand = myBuild.GetUpdateCommand();
然后跟踪得到的竟是
UPDATE [BS_DEPT] SET [ID_PARA] = @p1, [NO_DEPT] = @p2, [NM_DEPT] = @p3 WHERE (([ID_DEPT] = @p4) AND ((@p5 = 1 AND [ID_PARA] IS NULL) OR ([ID_PARA] = @p6)) AND ((@p7 = 1 AND [NO_DEPT] IS NULL) OR ([NO_DEPT] = @p8)) AND ((@p9 = 1 AND [NM_DEPT] IS NULL) OR ([NM_DEPT] = @p10)))
应该是
UPDATE [BS_DEPT] SET [ID_PARA] = @p1, [NO_DEPT] = @p2, [NM_DEPT] = @p3 WHERE ([ID_DEPT] = @p4)才对呀
------解决方案--------------------自动生成是比较所有的字段,你可以手动赋于SQL