X
xibaixin
Unregistered / Unconfirmed
GUEST, unregistred user!
我用ADO方式连接数据库,其中有一部分代码反复多次用,所以要用自定义过程,让他读出和写入数据库中表的记录。不用自定义过程也能用,那样代码太长。但是却有问题。
unit Choose;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, DB, ADODB;
type
TChooseForm = class(TForm)
Button1: TButton;
Edit1: TEdit;
ADOConnection1: TADOConnection;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
ChooseForm: TChooseForm;
implementation
uses Table;
var
xx1,xx2,kmsx,kmxx,bj,lsbh:integer;
xm,km,nj:string;
procedure TChooseForm.tkgc();变成 tkgc;也不行
begin
AdoTable1.FieldByName('科目').AsString:='算机' ;
end;
{$R *.dfm}
procedure TChooseForm.FormActivate(Sender: TObject);
var
AdoTable1:TAdoTable;
begin
AdoTable1:= TAdoTable.Create(self);
AdoTable1.Connection:=ADOConnection1;
AdoTable1.TableName:= '课表';
adoTable1.Active:=true;
end;
procedure TChooseForm.Button1Click(Sender: TObject);
var
AdoTable1:TAdoTable;
i,j,k,ii,mz,m:integer;
km0,mzzd:String;
begin
AdoTable1:= TAdoTable.Create(self);
AdoTable1.Connection:=ADOConnection1;
AdoTable1.TableName:= '课表';
AdoTable1.Active:=true;
while not AdoTable1.eof do
begin
if AdoTable1.FieldByName('编号').AsInteger=3 then
begin
tkgc;//变成TChooseForm.tkgc;也不行
end;
km:=AdoTable1.FieldByName('科目').AsString ;
end;
end.
这是代码的部分 就是存储记录的过程 指名表名不行,不指名表名也不行不知是什么原因,ADOConnection1;是拖进的 AdoTable1拖进也不行,AdoTable1
var
AdoTable1:TAdoTable;
begin
AdoTable1:= TAdoTable.Create(self);也不行;
如果不用过程实现是可以的 ,就是代码太长,提示AdoTable1 有问题
unit Choose;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, DB, ADODB;
type
TChooseForm = class(TForm)
Button1: TButton;
Edit1: TEdit;
ADOConnection1: TADOConnection;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
ChooseForm: TChooseForm;
implementation
uses Table;
var
xx1,xx2,kmsx,kmxx,bj,lsbh:integer;
xm,km,nj:string;
procedure TChooseForm.tkgc();变成 tkgc;也不行
begin
AdoTable1.FieldByName('科目').AsString:='算机' ;
end;
{$R *.dfm}
procedure TChooseForm.FormActivate(Sender: TObject);
var
AdoTable1:TAdoTable;
begin
AdoTable1:= TAdoTable.Create(self);
AdoTable1.Connection:=ADOConnection1;
AdoTable1.TableName:= '课表';
adoTable1.Active:=true;
end;
procedure TChooseForm.Button1Click(Sender: TObject);
var
AdoTable1:TAdoTable;
i,j,k,ii,mz,m:integer;
km0,mzzd:String;
begin
AdoTable1:= TAdoTable.Create(self);
AdoTable1.Connection:=ADOConnection1;
AdoTable1.TableName:= '课表';
AdoTable1.Active:=true;
while not AdoTable1.eof do
begin
if AdoTable1.FieldByName('编号').AsInteger=3 then
begin
tkgc;//变成TChooseForm.tkgc;也不行
end;
km:=AdoTable1.FieldByName('科目').AsString ;
end;
end.
这是代码的部分 就是存储记录的过程 指名表名不行,不指名表名也不行不知是什么原因,ADOConnection1;是拖进的 AdoTable1拖进也不行,AdoTable1
var
AdoTable1:TAdoTable;
begin
AdoTable1:= TAdoTable.Create(self);也不行;
如果不用过程实现是可以的 ,就是代码太长,提示AdoTable1 有问题