各位高手:
.....
self.ADOQuery3.sql.add('select '+a+' from '+edit1.Text+'');
self.ADOQuery3.open;
self.ADOQuery3.SaveToFile(d:/test.txt);
这样输入到txt中的是两句话
select name from login
select password from login
怎样在txt中出现name和password的数据阿
9 个解决方案
#1
你是要SQL查询语句?还是要查询的结果?
#2
我要保存数据,供调用
#3
有一个TEXT属性
#4
直接将查询到的结果写到 TStringList里面,再保存为文本文件
#5
while not self.adoQuery3.Eof do begin
StringGrid1.Cells[0,I]:=IntToStr(I);
StringGrid1.Cells[m,I ]:=L_format(trim(self.adoquery3.fieldbyname( '''+c+''').AsString) );
self.adoQuery3.Next;
inc(I);
end;
SaveDialog1:=TSaveDialog.Create(self);
SaveDialog1.Title:='保存文件';
SaveDialog1.InitialDir:='d:\mm\ ';
SaveDialog1.DefaultExt:= '"XLS" ';
SaveDialog1.FileName:= self.Caption;
SaveDialog1.Filter:='EXCEL文件(*.xls) |*.XLS ';
try
if SaveDialog1.Execute then
begin
case SaveDialog1.FilterIndex of
1: StringGrid1.SaveToXLS(SaveDialog1.FileName);
2: StringGrid1.SaveToASCII(SaveDialog1.FileName);
3: StringGrid1.SaveToHTML(SaveDialog1.FileName);
4: StringGrid1.SaveToCSV(SaveDialog1.FileName);
end;
Application.MessageBox( '文件保存成功!', ' ', MB_OK + MB_ICONASTERISK
+ MB_DEFBUTTON1 + MB_APPLMODAL);
end;
finally
这样会报错的,说savetoxls,savetoascii和savetohtmt没有定义,
还有 StringGrid1.Cells[m,I ]:=L_format(trim(self.adoquery3.fieldbyname( '''+c+''').AsString) );
c为变量,这样写不对,再加两个引号也不对阿。
谢谢
StringGrid1.Cells[0,I]:=IntToStr(I);
StringGrid1.Cells[m,I ]:=L_format(trim(self.adoquery3.fieldbyname( '''+c+''').AsString) );
self.adoQuery3.Next;
inc(I);
end;
SaveDialog1:=TSaveDialog.Create(self);
SaveDialog1.Title:='保存文件';
SaveDialog1.InitialDir:='d:\mm\ ';
SaveDialog1.DefaultExt:= '"XLS" ';
SaveDialog1.FileName:= self.Caption;
SaveDialog1.Filter:='EXCEL文件(*.xls) |*.XLS ';
try
if SaveDialog1.Execute then
begin
case SaveDialog1.FilterIndex of
1: StringGrid1.SaveToXLS(SaveDialog1.FileName);
2: StringGrid1.SaveToASCII(SaveDialog1.FileName);
3: StringGrid1.SaveToHTML(SaveDialog1.FileName);
4: StringGrid1.SaveToCSV(SaveDialog1.FileName);
end;
Application.MessageBox( '文件保存成功!', ' ', MB_OK + MB_ICONASTERISK
+ MB_DEFBUTTON1 + MB_APPLMODAL);
end;
finally
这样会报错的,说savetoxls,savetoascii和savetohtmt没有定义,
还有 StringGrid1.Cells[m,I ]:=L_format(trim(self.adoquery3.fieldbyname( '''+c+''').AsString) );
c为变量,这样写不对,再加两个引号也不对阿。
谢谢
#6
怎么没有人呢
#7
采用ADO的recordset进行循环输入检索到的值不就可以了吗、
#8
具体可以写一下吗,解决了马上分分阿
#9
还是没有人a
#1
你是要SQL查询语句?还是要查询的结果?
#2
我要保存数据,供调用
#3
有一个TEXT属性
#4
直接将查询到的结果写到 TStringList里面,再保存为文本文件
#5
while not self.adoQuery3.Eof do begin
StringGrid1.Cells[0,I]:=IntToStr(I);
StringGrid1.Cells[m,I ]:=L_format(trim(self.adoquery3.fieldbyname( '''+c+''').AsString) );
self.adoQuery3.Next;
inc(I);
end;
SaveDialog1:=TSaveDialog.Create(self);
SaveDialog1.Title:='保存文件';
SaveDialog1.InitialDir:='d:\mm\ ';
SaveDialog1.DefaultExt:= '"XLS" ';
SaveDialog1.FileName:= self.Caption;
SaveDialog1.Filter:='EXCEL文件(*.xls) |*.XLS ';
try
if SaveDialog1.Execute then
begin
case SaveDialog1.FilterIndex of
1: StringGrid1.SaveToXLS(SaveDialog1.FileName);
2: StringGrid1.SaveToASCII(SaveDialog1.FileName);
3: StringGrid1.SaveToHTML(SaveDialog1.FileName);
4: StringGrid1.SaveToCSV(SaveDialog1.FileName);
end;
Application.MessageBox( '文件保存成功!', ' ', MB_OK + MB_ICONASTERISK
+ MB_DEFBUTTON1 + MB_APPLMODAL);
end;
finally
这样会报错的,说savetoxls,savetoascii和savetohtmt没有定义,
还有 StringGrid1.Cells[m,I ]:=L_format(trim(self.adoquery3.fieldbyname( '''+c+''').AsString) );
c为变量,这样写不对,再加两个引号也不对阿。
谢谢
StringGrid1.Cells[0,I]:=IntToStr(I);
StringGrid1.Cells[m,I ]:=L_format(trim(self.adoquery3.fieldbyname( '''+c+''').AsString) );
self.adoQuery3.Next;
inc(I);
end;
SaveDialog1:=TSaveDialog.Create(self);
SaveDialog1.Title:='保存文件';
SaveDialog1.InitialDir:='d:\mm\ ';
SaveDialog1.DefaultExt:= '"XLS" ';
SaveDialog1.FileName:= self.Caption;
SaveDialog1.Filter:='EXCEL文件(*.xls) |*.XLS ';
try
if SaveDialog1.Execute then
begin
case SaveDialog1.FilterIndex of
1: StringGrid1.SaveToXLS(SaveDialog1.FileName);
2: StringGrid1.SaveToASCII(SaveDialog1.FileName);
3: StringGrid1.SaveToHTML(SaveDialog1.FileName);
4: StringGrid1.SaveToCSV(SaveDialog1.FileName);
end;
Application.MessageBox( '文件保存成功!', ' ', MB_OK + MB_ICONASTERISK
+ MB_DEFBUTTON1 + MB_APPLMODAL);
end;
finally
这样会报错的,说savetoxls,savetoascii和savetohtmt没有定义,
还有 StringGrid1.Cells[m,I ]:=L_format(trim(self.adoquery3.fieldbyname( '''+c+''').AsString) );
c为变量,这样写不对,再加两个引号也不对阿。
谢谢
#6
怎么没有人呢
#7
采用ADO的recordset进行循环输入检索到的值不就可以了吗、
#8
具体可以写一下吗,解决了马上分分阿
#9
还是没有人a