2,497
社区成员
发帖
与我相关
我的任务
分享
con1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+MyExcelFile+';Extended Properties=excel 8.0;Persist Security Info=False';
con1.Connected:=true;
qry1.Close;
qry1.SQL.Clear;
qry1.SQL.Add('SELECT * FROM [sheet1$]');
qry1.Open;
pb1.Max:=qry1.RecordCount;
lbl1.Caption:='0';
lbl2.Caption:='0';
for i:=1 to qry1.RecordCount do
begin
Application.ProcessMessages;
self.refresh;
qry2.Close;
qry2.SQL.Clear;
qry2.SQL.Add('select * from aa ');
qry2.Open;
//if ADOQuery2.FieldByName('csbh').AsString='' then
//begin
lbl1.Caption:=IntToStr(StrTOint(lbl1.caption)+1);
// ShowMessage(IntToStr(ADOQuery2.RecordCount));
qry2.Close;
qry2.SQL.Clear;
qry2.SQL.Add('insert into aa(q1,q2,ddate,flag)');
qry2.SQL.Add('Values('+QuotedStr(qry1.fieldbyName('q1).AsString)+','+QuotedStr(qry1.fieldbyName('q2').AsString)+',getdate(),0)');
// ShowMessage(ADOQuery2.SQL.text);
try
qry2.ExecSQL;
except
end;
Application.ProcessMessages;
qry1.Next;
pb1.Position :=i;
end;
qry2.Active:=false;
qry2.Close;
qry2.SQL.Add('select * from aa);
qry2.Open;
qry2.Active:=true;
Application.MessageBox('导入完毕!','提示',MB_OK+MB_Iconinformation);