接Memo1的处理
在Adoquery表里有以下数据,
名称 中奖号码
特等奖 6A08
特等奖 203
四等奖 5009
四等奖 3109
四等奖 907
四等奖 16A03
四等奖 1305
四等奖 36A06
四等奖 308
四等奖 3906
四等奖 2507
四等奖 1311
三等奖 1005
三等奖 5509
三等奖 209
三等奖 3504
三等奖 3A02
一等奖 1805
现在要求在 Memo1 显示如下
特等奖
6A08 203
四等奖
5009 3109
907 16A03
.......................
三等奖
1005 5509
............................
在Adoquery表里有以下数据,
名称 中奖号码
特等奖 6A08
特等奖 203
四等奖 5009
四等奖 3109
四等奖 907
四等奖 16A03
四等奖 1305
四等奖 36A06
四等奖 308
四等奖 3906
四等奖 2507
四等奖 1311
三等奖 1005
三等奖 5509
三等奖 209
三等奖 3504
三等奖 3A02
一等奖 1805
现在要求在 Memo1 显示如下
特等奖
6A08 203
四等奖
5009 3109
907 16A03
.......................
三等奖
1005 5509
............................
解决方案 »
- 求8、16、24转32色深的函数
- delphi2010的几点疑问
- 如何获取当前时间(单位:秒)与标准时间(1900/01/01/00:00)的差呢?
- 有请高手!
- 救命!!
- 在delphi7中的dbgrid控件中怎样显示一个checkbox样式的字段?????
- 请问那里有关于pop3和idmessages的资料啊(delphi7.0的)?
- @@@@时间加减的简单问题,在线等待@@@@
- 怎么引用REMOTEDATAMODUAL上的控件?(如ADOCONNECTION)
- HI这个函数常用吗?
- 请问combobox如何实现readonly属性?
- 如何单独放置控件到PageControl1上并每页做单独处理??
var
i:integer;
strCurMC:string;
strLine:string;
iPos:integer;
begin
AdoQuery1.Close;
AdoQuery1.Sql.Text:='select * from Table order by 名称';
AdoQuery1.Open; strCurMC:='';
strLIne:='';
iPos:=0;
for i:=0 to AdoQuery1.RecordCount-1 do
begin
if strCurMC<>AdoQuery1.FieldByName('名称').AsString then
begin
strCurMC:=AdoQuery1.FieldByName('名称').AsString;
Memo1.Lines.Add(strCurMC);
end;
strLIne:=strLIne+' '+AdoQuery1.FieldByName('中奖号码').AsString;
inc(iPos);
if iPos=2 then
begin
Memo1.Lines.Add(strLine);
strLIne:='';
iPos:=0;
end; AdoQuery1.Next;
end;
I,J: Integer;
str, strField, strValue: string;
begin
...
Adoquery.First;
strField := '';
str := '';
J := 1;
for i := 0 to Adoquery.RecordCount - 1 do
with Adoquery do begin
if strField <> FieldByName('名称').AsString then begin
if str <> '' then
Memo1.Lines.Add(str);
strField := FieldByName('名称').AsString
Memo1.Lines.Add(strField);
str := ' ' + FieldByName('中奖号码').AsString;
J := 1;
Adoquery.Next;
if Adoquery.Eof then begin
Memo1.Lines.Add(str);
end;
continue;
end; str := str + ' ' + FieldByName('中奖号码').AsString;
Inc(J);
Adoquery.Next; if (J = 2) or Adoquery.Eof then begin
Memo1.Lines.Add(str);
str := '';
J := 1;
end;
end;
end;
var
Line, Level: string;
begin
ADOQuery1.DisableControls;
Memo1.Lines.BeginUpdate;
try
ADOQuery1.Close;
ADOQuery1.SQL.Text := 'select 名称 中奖号码 from 获奖人员表 order by 名称';
ADOQuery1.Open;
Memo1.Lines.Clear;
if ADOQuery1.Eof then Exit; Level := ADOQuery1.Fields[0].AsString;
Memo1.Lines.Add(Level);
while not ADOQuery1.Eof do
begin
if not SameText(Level, ADOQuery1.Fields[0].AsString) then
begin
Level := ADOQuery1.Fields[0].AsString;
Memo1.Lines.Add(Level);
end; Line := StringOfChar(' ', 6) + ADOQuery1.Fields[1].AsString; ADOQuery1.Next;
//检测没有记录或者已经不是上一次的得奖等级,那么就把Line加入Memo1中
if ADOQuery1.Eof or not SameText(Level, ADOQuery1.Fields[0].AsString) then
begin
Memo1.Lines.Add(Line);
Continue;
end
else
begin
//如果还是上一次得奖等级,还记录,就串连
Line := Line + StringOfChar(' ', 6) + ADOQuery1.Fields[1].AsString;
Memo1.Lines.Add(Line);
end; ADOQuery1.Next;
end;
finally
ADOQuery1.EnableControls;
Memo1.Lines.EndUpdate;
end;
end;
不应该没数据显示,是不是查询没有结果? AdoQuery1.Close;
AdoQuery1.Sql.Text:='select * from Table order by 名称';
AdoQuery1.Open; AdoQuery1.Last;///加这一句
strCurMC:='';
strLIne:='';
iPos:=0;
var
I,J: Integer;
str, strField, strValue: string;
begin
...
Adoquery.First;
strField := '';
str := '';
J := 1;
for i := 0 to Adoquery.RecordCount - 1 do
with Adoquery do begin
if strField <> FieldByName('名称').AsString then begin
if str <> '' then
Memo1.Lines.Add(str);
strField := FieldByName('名称').AsString;
Memo1.Lines.Add(strField);
str := ' ' + FieldByName('中奖号码').AsString;
J := 1;
Adoquery.Next;
if Adoquery.Eof then begin
Memo1.Lines.Add(str);
end;
continue;
end; str := str + ' ' + FieldByName('中奖号码').AsString;
Inc(J);
Adoquery.Next; if (J = 2) or Adoquery.Eof then begin
Memo1.Lines.Add(str);
str := '';
J := 0;
end; end;
end;
var
i:integer;
strCurMC:string;
strLine:string;
iPos:integer;
begin
AdoQuery1.Close;
AdoQuery1.Sql.Text:='select * from Table1 order by 名称';
AdoQuery1.Open;
AdoQuery1.Last;
AdoQuery1.First; strCurMC:='';
strLIne:='';
iPos:=0;
for i:=0 to AdoQuery1.RecordCount-1 do
begin
if strCurMC<>AdoQuery1.FieldByName('名称').AsString then
begin
if (iPos=1) and (Length(strLine)>0) then
Memo1.Lines.Add(strLine);
strCurMC:=AdoQuery1.FieldByName('名称').AsString;
Memo1.Lines.Add(strCurMC);
strLIne:='';
iPos:=0;
end;
strLIne:=strLIne+' '+AdoQuery1.FieldByName('号码').AsString;
inc(iPos);
if iPos=2 then
begin
Memo1.Lines.Add(strLine);
strLIne:='';
iPos:=0;
end; AdoQuery1.Next;
end;
if (iPos=1) and (Length(strLine)>0) then
Memo1.Lines.Add(strLine);
end;