A
azyee
Unregistered / Unconfirmed
GUEST, unregistred user!
我想作delphi下access数据库表的报表,排序后在另一个表里显示出来,同时要有对原表的改写功能,最后做个条形示意图.
这周是最后期限,可是我连排序都搞不定...这是我的代码:
unit Unitff2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, ExtCtrls, DBCtrls, Grids, DBGrids, StdCtrls;
type
TForm1 = class(TForm)
DataSource1: TDataSource;
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
ADOConnection1: TADOConnection;
ADOTable1: TADOTable;
Button1: TButton;
ADOQuery1: TADOQuery;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
ADOQuery1.open
Select ttttt."学号"
FROM ":aboutdelphi: ttttt"
Order By ttttt."学号"
DESC ;
end;
end.
每次运行到
Select ttttt."学号"
就报错:missing operator or semicolon
illegal character in input file:'"' ($22)
后来我又写了个冒泡法:
unit testtest2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, ExtCtrls, DBCtrls, Grids, DBGrids, StdCtrls;
type
TForm1 = class(TForm)
DataSource1: TDataSource;
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
ADOConnection1: TADOConnection;
ADOTable1: TADOTable;
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioGroup1: TRadioGroup;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
max : integer;
num1 : integer;
num2 : integer;
count1 : integer;
count11 : integer;
count2 : integer;
count3 : integer;
P1 : single;
P2 : single;
a : single;
begin
max := (query1.RecordCount)/4 ;
for count1 := 1 to (max-1) do
begin
query1.First ;
for count11 := 1 to (count1 - 1) do
begin
query1.Next ;
end;
num1 := query1.fieldByName('学号').Value ;
P1 := query1.FieldByName('语文').value ;
for count2 := count1 + 1 to (max - count1) do
begin
query1.First ;
query1.MoveBy(count2 - 1);
num2 := query1.fieldByName('学号').Value ;
P2 := query1.fieldbyName('语文').Value ;
with query1 do
begin
if P1 < P2 then
begin
a = P1 ;
query1.SQL.Clear ;
query1.SQL.Add('update adv');
query1.SQL.Add('set query1.fieldByName('学号').Value = P2 where num='+inttostr(num1));
query1.SQL.Add('set query1.fieldByName('学号').Value = a where num='+inttostr(num2));
query1.ExecSQL ;
query1.SQL.Clear ;
query1.SQL.Add('select * from adv');
query1.open;
UPDATE ":TAB: aaa"
end;
end;
end;
end;
end;
SET ttttt."学号"=P2 where num='+inttostr(num1));
SET ttttt."学号"=a where num='+inttostr(num2));
end.
错误更是铺天盖地,我已经走投无路了...有高手愿意帮我吗?
这周是最后期限,可是我连排序都搞不定...这是我的代码:
unit Unitff2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, ExtCtrls, DBCtrls, Grids, DBGrids, StdCtrls;
type
TForm1 = class(TForm)
DataSource1: TDataSource;
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
ADOConnection1: TADOConnection;
ADOTable1: TADOTable;
Button1: TButton;
ADOQuery1: TADOQuery;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
ADOQuery1.open
Select ttttt."学号"
FROM ":aboutdelphi: ttttt"
Order By ttttt."学号"
DESC ;
end;
end.
每次运行到
Select ttttt."学号"
就报错:missing operator or semicolon
illegal character in input file:'"' ($22)
后来我又写了个冒泡法:
unit testtest2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, ExtCtrls, DBCtrls, Grids, DBGrids, StdCtrls;
type
TForm1 = class(TForm)
DataSource1: TDataSource;
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
ADOConnection1: TADOConnection;
ADOTable1: TADOTable;
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioGroup1: TRadioGroup;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
max : integer;
num1 : integer;
num2 : integer;
count1 : integer;
count11 : integer;
count2 : integer;
count3 : integer;
P1 : single;
P2 : single;
a : single;
begin
max := (query1.RecordCount)/4 ;
for count1 := 1 to (max-1) do
begin
query1.First ;
for count11 := 1 to (count1 - 1) do
begin
query1.Next ;
end;
num1 := query1.fieldByName('学号').Value ;
P1 := query1.FieldByName('语文').value ;
for count2 := count1 + 1 to (max - count1) do
begin
query1.First ;
query1.MoveBy(count2 - 1);
num2 := query1.fieldByName('学号').Value ;
P2 := query1.fieldbyName('语文').Value ;
with query1 do
begin
if P1 < P2 then
begin
a = P1 ;
query1.SQL.Clear ;
query1.SQL.Add('update adv');
query1.SQL.Add('set query1.fieldByName('学号').Value = P2 where num='+inttostr(num1));
query1.SQL.Add('set query1.fieldByName('学号').Value = a where num='+inttostr(num2));
query1.ExecSQL ;
query1.SQL.Clear ;
query1.SQL.Add('select * from adv');
query1.open;
UPDATE ":TAB: aaa"
end;
end;
end;
end;
end;
SET ttttt."学号"=P2 where num='+inttostr(num1));
SET ttttt."学号"=a where num='+inttostr(num2));
end.
错误更是铺天盖地,我已经走投无路了...有高手愿意帮我吗?