首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

无法运行。解决方法

2012-02-20 
无法运行。。在dataconnection下面的代码如下:procedureTData.DataModuleCreate(Sender:TObject)varini:tIn

无法运行。。
在dataconnection下面的代码如下:
procedure   TData.DataModuleCreate(Sender:   TObject);
var         ini:tIniFile;
              strserver,strname,strpassword:string;
begin
ini:=tinifile.Create(extractfilepath(paramstr(0))+ '\cserver.ini ');
strserver:=ini.ReadString( 'server ', 'server ', 'server ');
strname:=ini.ReadString( 'name ', 'name ', 'sa ');
strpassword:=ini.ReadString( 'password ', 'password ', ' ');
try
adoconnection1.ConnectionString:= 'Provider=SQLOLEDB.1;Persist   Security   Info=False;User   ID= '+strname+ ';Initial   Catalog=studten;Data   Source= '+strserver+ ';password= '+strpassword;
adoconnection1.Connected:=true;
except
exit;
end;
end;  


在程序窗口的代码

procedure   TForm1.FormCreate(Sender:   TObject);
begin
      adoquery1.Connection:=data.ADOConnection1;
      adoquery1.Active:=true;
      adoquery1.Close;
      adoquery1.SQL.Clear;
      adoquery1.SQL.Add( 'select   *   form   t_writes ');
      adoquery1.Open;
end;


但每次运行的时间都会提示出错,
Project   P1.exe   raised   exception   class,   EAccessVonlation   with   message '   access   violation   at   address   004A94F2   in   moule   p1.exe   '.   read   of   address   00000058.

我是菜鸟,刚学不久,请赐教!是什么原因!


[解决办法]
打开工程文件,看TData是不是在TForm1之前Create了
[解决办法]
首先给你指一个错误,在procedure TData.DataModuleCreate(Sender: TObject);中
ini在函数结束的时候最好释放掉.ini.free;

提示这种错误,就是对象没有创建就使用了,看样子好象是adoquery1没有创建吧。
提出错误提示停在了那条语句上?
[解决办法]
把工程文件贴出来

热点排行