我还未学过Delphi,我想向各位请教以下问题:
我想用ADO连接Oracle数据库(用户名:user,密码:pass,server:server),执行一个SQL语句("select a,b,count(c) from d where to_char(o_date,'yyyymmdd') between "+the_date +"group by a,b"),the_date从窗体上的DropDownListBox控件选出,然后将结果写入一个文本文件result.txt,字段间用逗号分开,写完一行后换行,直至写完所有数据,然后用系统中.txt文件默认关联的程序打开该文件。
我想这个程序不太难,我想把他作为学习这门语言的开始,请不吝赐教提供源码。
我想用ADO连接Oracle数据库(用户名:user,密码:pass,server:server),执行一个SQL语句("select a,b,count(c) from d where to_char(o_date,'yyyymmdd') between "+the_date +"group by a,b"),the_date从窗体上的DropDownListBox控件选出,然后将结果写入一个文本文件result.txt,字段间用逗号分开,写完一行后换行,直至写完所有数据,然后用系统中.txt文件默认关联的程序打开该文件。
我想这个程序不太难,我想把他作为学习这门语言的开始,请不吝赐教提供源码。
讲个大概也好
我会用VB作,但是对Delphi 语法不熟,不知怎样下手
2,用Adoquery控件,connect设成Database,设置SQL属性,就是查询用的SQL语句,查出结果集
3,一条一条选出,存为文件,
4,调用系统程序,打开刚才的即使本文件!
我现在不知该如何再循环写数据时判断记录集的结尾,就象eof
我该怎么作呢?
DBGrid+ADOQuery
var
mm:String;
begin
mm:=ADOQuery1.FieldByName('字段名').AnString;
end;
ADOQuery自动记录光标位置。
begin
;//
end;
while not adoquery.eof do
begin
mm:=ADOQuery1.FieldByName('字段名').AnString;
adoquery.Next;
end;
Reset(fText);
while not Eof(fText) do
begin
Readln(fText,strLine);
strLine:=Trim(strLine);
Combo_user.Items.Add(strLine);
if combo_user.Items.Count=10 then
begin
break;
end;
end;
CloseFile(fText);
//初始化COM_USER数据 从文本中读出USER
//从COMBOBOX中写入
for i:=0 to combo_user.Items.Count do
begin
if trim(Combo_user.Text)=trim(combo_user.Items.Strings[i]) then
begin
flag:=true; //意味着存在相同的字段;
end;
end;
end;
if not flag then //意味着不存在相同的字段;
begin
combo_user.Items.Insert(0,trim(combo_user.Text));
end;
for j:=1 to combo_user.Items.Count do
begin
combo_user.Items.SaveToFile('login.txt');
end;
另外最近CSDN太难上了,总出500错,愁死我了:(procedure TForm1.Button1Click(Sender: TObject);
begin
//adoquery1.sql.Add ('select deptno from dept_info');
adoquery1.ExecSQL;
while not adoquery1.eof do
begin
mm:=mm+ADOQuery1.FieldByName('deptno').AsString;
adoquery1.Next;
end;
Memo1.Lines.Add(mm);
//fText:='c:\test.txt';
//AssignFile(Output, 'c:\test.txt');
//Rewrite(Output);
//write (mm);
//CloseFile('c:\test.txt');
showmessage('ok');
end;
begin
//adoquery1.sql.Add ('select deptno from dept_info');
adoquery1.Open;//改这儿
while not adoquery1.eof do
begin
mm:=mm+ADOQuery1.FieldByName('deptno').AsString;
Memo1.Lines.Add(mm);
adoquery1.Next;
end;
//fText:='c:\test.txt';
//AssignFile(Output, 'c:\test.txt');
//Rewrite(Output);
//write (mm);
//CloseFile('c:\test.txt');
showmessage('ok');
end;