说明:我连接的数据库是RACLE,to_bi和to_xd都能连接到ORACLE数据库我建了一个DataModule单元,其中包含两个连接(to_bi和to_xd,即TADOConnection)。内容如下:
unit data_my;interfaceuses
SysUtils, Classes, DB, ADODB;type
TDataModule2 = class(TDataModule)
to_bi: TADOConnection;
to_xd: TADOConnection;
private
{ Private declarations }
public
{ Public declarations }
end;var
DataModule2: TDataModule2;implementation{$R *.dfm}end.---------------------------------------------------------------------
我在登录表单使用了to_xd,当程序执行到ADOQuery1.Connection:=datamodule2.to_xd;时就提示错误:
Access violation at address 005085CD in module 'yyy.exe'. Read of address 0000005C.unit quanxian;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, StdCtrls;type
TForm3 = class(TForm)
Label1: TLabel;
Label2: TLabel;
uname: TEdit;
upass: TEdit;
Button1: TButton;
Button2: TButton;
ADOQuery1: TADOQuery;
ADOConnection1: TADOConnection;
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form3: TForm3;implementation//uses data_my,func;{$R *.dfm}procedure TForm3.FormShow(Sender: TObject);
begin
ADOQuery1.Connection:=datamodule2.to_xd; //执行到这里出错
end;end.
---------------------------------------------------------------------
奇怪的是,在其他表单使用to_xd连接数据库不会提示错误
procedure TForm1.FormCreate(Sender: TObject);
begin
adoquery1.Connection:=datamodule2.to_xd;
end;
---------------------------------------------------------------------
请问各位高手,为什么在登录表单里执行到ADOQuery1.Connection:=datamodule2.to_xd;就会提示内存错误,而在其他表单不会提示错误,如何解决?
unit data_my;interfaceuses
SysUtils, Classes, DB, ADODB;type
TDataModule2 = class(TDataModule)
to_bi: TADOConnection;
to_xd: TADOConnection;
private
{ Private declarations }
public
{ Public declarations }
end;var
DataModule2: TDataModule2;implementation{$R *.dfm}end.---------------------------------------------------------------------
我在登录表单使用了to_xd,当程序执行到ADOQuery1.Connection:=datamodule2.to_xd;时就提示错误:
Access violation at address 005085CD in module 'yyy.exe'. Read of address 0000005C.unit quanxian;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, StdCtrls;type
TForm3 = class(TForm)
Label1: TLabel;
Label2: TLabel;
uname: TEdit;
upass: TEdit;
Button1: TButton;
Button2: TButton;
ADOQuery1: TADOQuery;
ADOConnection1: TADOConnection;
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form3: TForm3;implementation//uses data_my,func;{$R *.dfm}procedure TForm3.FormShow(Sender: TObject);
begin
ADOQuery1.Connection:=datamodule2.to_xd; //执行到这里出错
end;end.
---------------------------------------------------------------------
奇怪的是,在其他表单使用to_xd连接数据库不会提示错误
procedure TForm1.FormCreate(Sender: TObject);
begin
adoquery1.Connection:=datamodule2.to_xd;
end;
---------------------------------------------------------------------
请问各位高手,为什么在登录表单里执行到ADOQuery1.Connection:=datamodule2.to_xd;就会提示内存错误,而在其他表单不会提示错误,如何解决?
解决方案 »
- DataSetProvider.updatemode
- delphi编码中的汉字都变成了小方框
- 把分都还给你哦
- 如何能操作activeX里的控件???
- 如何设置MediaPlayer的播放次数和一直循环?
- class TMemo not found
- 谁能告诉我关于查两个表的查询语句的写法。(不是一般的两个表字段合并)
- 有数据库源程序的请进来(100)
- select max(con1,con2) as con3 from table 对不对?
- 请教各位,怎样判断在edit1.text中输入的是数安还是字符??
- 如何查找运行的进程中是否存在某个进程?如abc.exe
- 求问:如何将BDgrid中数据存入到其他表中
这一句应是uses data_my,func;
发帖时忘了删除//