M
microrain
Unregistered / Unconfirmed
GUEST, unregistred user!
我自己写了一个小的单元测试。想要实现ADO操作的简单封装。便于我其它窗口的调用。
可是包含到其它窗口单元中后,一调用就出错。说mycomm.CommandText :='select * from commandlist';
不能赋值。帮帮忙呀,高手们!
unit GlobalAdo;
interface
uses
Windows, SysUtils, Classes, OleCtrls, Dialogs,ADODB,forms;
type
TadoDB = class
TxtMsg:String;
Procedure getValue(tmsg:String);
end;
var
MyConn:TADOConnection;
MyComm:TADOCommand;
Mydats:TADODataSet;
implementation
Procedure TadoDB.getValue(tmsg:String);
var
spath:string;
begin
MyConn:=TADOConnection.Create(application);
spath:=extractfilepath(application.ExeName )+'data/clientdb.mdb';
MyConn.Connectionstring:='Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source='+spath;
myconn.loginprompt:=false;
myconn.Connected :=true;
mycomm.CommandText :='select * from commandlist';
mycomm.Execute;
end;
end.
可是包含到其它窗口单元中后,一调用就出错。说mycomm.CommandText :='select * from commandlist';
不能赋值。帮帮忙呀,高手们!
unit GlobalAdo;
interface
uses
Windows, SysUtils, Classes, OleCtrls, Dialogs,ADODB,forms;
type
TadoDB = class
TxtMsg:String;
Procedure getValue(tmsg:String);
end;
var
MyConn:TADOConnection;
MyComm:TADOCommand;
Mydats:TADODataSet;
implementation
Procedure TadoDB.getValue(tmsg:String);
var
spath:string;
begin
MyConn:=TADOConnection.Create(application);
spath:=extractfilepath(application.ExeName )+'data/clientdb.mdb';
MyConn.Connectionstring:='Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source='+spath;
myconn.loginprompt:=false;
myconn.Connected :=true;
mycomm.CommandText :='select * from commandlist';
mycomm.Execute;
end;
end.