晕了,就这样结贴偶不甘心啊 :)
现在我是这样做的:
procedure SetXls_DescToValue(ADOCmd:TAdoCommand;const fname,SheetName:String;
const FieldLst:TStrings;DictLst:TMyItemList);
var
StrOpenDB:String;
i, iPosOfItem, j : Integer;
sSQL : String;
begin
StrOpenDB:='OpenDataSource(''Microsoft.Jet.OLEDB.4.0'', ''Data Source='+fname+';User ID=Admin;Password=;Extended properties=Excel 5.0'')...['+SheetName+'$]';
for i:=0 to FieldLst.Count-1 do
begin
if (FieldLst[i][1]='i') and (FieldLst[i][2]='m') then //Èç¹ûÊÇim×Ö¶Î
begin
iPosOfItem := DictLst.IndexOf(FieldLst[i]);
if iPosOfItem<>-1 then
begin
for j:=0 to DictLst.Items[iPosOfItem].DescList.Count-1 do
begin
sSQL := 'Update '+StrOpenDB+' set '+FieldLst[i]+'='''
+ DictLst.Items[iPosOfItem].GetValueByDesc( DictLst.Items[iPosOfItem].DescList[j] )
+ ''' where '+FieldLst[i]+'='''+DictLst.Items[iPosOfItem].DescList[j]+'''';
Application.ProcessMessages;
ADOCmd.CommandText := sSQL;
//LogT('¿ªÊ¼Exec',[],True);
ADOCmd.Execute;
//LogT('Íê³ÉExec'+DictLst.Items[iPosOfItem].DescList[j],[],False);
end;
end;
end
end;
end;