delphi7 如何将文本文件中的数据添加到数据库中
展开全部
数据库是ACCESS还是sql?试试吧,我还没试,作为参考
一、将表中数据导出到文本文件(TXT):
Select * INTO [TEXT;DATABASE=E:\TEMP].TESTABC.txt FROM Sheet2;
二、导入TXT文件并生成新表:
Select * INTO ABC FROM [TEXT;DATABASE=E:\TEMP].TESTABC.txt;
三、将TXT文件导入到一个现有表中:
Insert INTO ABC Select * FROM [TEXT;DATABASE=E:\TEMP].TESTABC.txt;
TXT->Access:
procedure TForm1.Button2Click(Sender: TObject);
var
str:string;
begin
str:= 'select * into form from [Text;Database=d:\].3.txt';
with AccessConnection do
begin
Connected := True;
Execute(str);
end;
end;
Access->txt:
procedure TForm1.Button1Click(Sender: TObject);
var
ssql:string;
begin
sSql := 'select * into [Text;Database=d:\].aaa.txt from form';
with AccessConnection do
begin
Connected := True;
Execute(sSql);
end;
end;
一、将表中数据导出到文本文件(TXT):
Select * INTO [TEXT;DATABASE=E:\TEMP].TESTABC.txt FROM Sheet2;
二、导入TXT文件并生成新表:
Select * INTO ABC FROM [TEXT;DATABASE=E:\TEMP].TESTABC.txt;
三、将TXT文件导入到一个现有表中:
Insert INTO ABC Select * FROM [TEXT;DATABASE=E:\TEMP].TESTABC.txt;
TXT->Access:
procedure TForm1.Button2Click(Sender: TObject);
var
str:string;
begin
str:= 'select * into form from [Text;Database=d:\].3.txt';
with AccessConnection do
begin
Connected := True;
Execute(str);
end;
end;
Access->txt:
procedure TForm1.Button1Click(Sender: TObject);
var
ssql:string;
begin
sSql := 'select * into [Text;Database=d:\].aaa.txt from form';
with AccessConnection do
begin
Connected := True;
Execute(sSql);
end;
end;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询