2,497
社区成员
发帖
与我相关
我的任务
分享
procedure TFormConfig.Button1Click(Sender: TObject);
var
SQLStr:string;
ms:TStringList;
begin
access:=ExtractFilePath(Application.ExeName)+'.\db.mdb'; //获取绝对路径
adoconnection2.Connected:=false;
ADOConnection2.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+access+';'+'Persist Security Info=False';
ms:=TStringList.Create;
ADOConnection2.GetTableNames(ms);
if ms.IndexOf(MyNumber.Text)<0 then
begin
SQLStr:='select * into '+MyNumber.Text+' FROM [excel 8.0;database='+excel.Text+'].['+ComboBox1.Text+'$]';
ADOConnection2.Execute(SQLStr);
adoconnection2.Connected:=true;
showmessage('数据导入成功!');
end
else
showmessage('请输入正确数据!');
end;