MyTable1不能直接修改MySQL中一条记录吗?(200分)

  • 主题发起人 主题发起人 wino
  • 开始时间 开始时间
W

wino

Unregistered / Unconfirmed
GUEST, unregistred user!
想用MyDAC中的MyTable来修改MySQL DB中的一些数据,因为DB中有一个ID字段是自增长的,用SQL语句修改记录时,ID不能保存原来的值,所以想用如下方法修改其中的某些字段:<br><br>if MyTable1.FindKey([FileInfo.MD5]) &nbsp;then<br>begin<br>&nbsp; &nbsp; with MyTable1 do<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; ReadOnly := False;<br>&nbsp; &nbsp; &nbsp; &nbsp; Edit;<br>&nbsp; &nbsp; &nbsp; &nbsp; FieldValues['FileName'] := FileInfo.FileName;<br>&nbsp; &nbsp; &nbsp; &nbsp; FieldValues['UploadDate'] := FileInfo.UpLoadDate;<br>&nbsp; &nbsp; &nbsp; &nbsp; FieldValues['DicType'] := FileInfo.DicType;<br>&nbsp; &nbsp; &nbsp; &nbsp; FieldValues['Path'] := FileInfo.Path;<br>&nbsp; &nbsp; &nbsp; &nbsp; //方法二<br>&nbsp; &nbsp; &nbsp; &nbsp; //FieldByName('FileName').AsString := FileInfo.FileName;<br>&nbsp; &nbsp; &nbsp; &nbsp; //FieldByName('UploadDate').AsString := FileInfo.UpLoadDate;<br>&nbsp; &nbsp; &nbsp; &nbsp; //FieldByName('DicType').AsInteger := FileInfo.DicType;<br>&nbsp; &nbsp; &nbsp; &nbsp; //FieldByName('Path').AsString := FileInfo.Path;<br>&nbsp; &nbsp; &nbsp; &nbsp; //Update;<br>&nbsp; &nbsp; &nbsp; &nbsp; UpdateRecord;<br>&nbsp; &nbsp; &nbsp; &nbsp; Post;<br>&nbsp; &nbsp; end;<br>end;<br><br>上面两种方法都修改不了,执行后还是原来的数据,有兄弟知道吗?谢谢
 

Similar threads

D
回复
0
查看
867
DelphiTeacher的专栏
D
D
回复
0
查看
836
DelphiTeacher的专栏
D
D
回复
0
查看
785
DelphiTeacher的专栏
D
后退
顶部