阿
阿梅
Unregistered / Unconfirmed
GUEST, unregistred user!
在数据模块(远程)的函数DBConnect:
type
TPKGL = class(TRemoteDataModule, IPKGL)
........
private
{ Private declarations }
protected
{ Private declarations }
public
function DBConnect(aServerName, aDatabaseName, aUserName, aPassword: string): boolean;
{ Public declarations }
end;
function TPKGL.DBConnect(aServerName, aDatabaseName, aUserName, aPassword: string): boolean;
var
connStr: string;
begin
Result := True;
Connstr := 'Provider=SQLOLEDB.1;Password=' + aPassword + ';Persist Security Info=True;User ID=' + aUserName + ';Initial Catalog='+ aDatabaseName +';Data Source=' + aServerName;
try
if not ErpDBC.Connected then
begin
ErpDBC.ConnectionString := Connstr;
ErpDBC.DefaultDatabase := aDatabaseName;
ErpDBC.Open;
end;
except
messagebox(application.handle, '配置SQLSERVER数据库出错!', '提示!', 0);
Result := False;
end;
end;
同时在服务器端建一form窗口,却在form上无法调用数据模块DataModule的函数DBConnect,在form上已uses PKGL_RDB(数据模块),代码如下:
procedure TfrmMain.FormCreate(Sender: TObject);
var
serverName, databaseName, userName, password: string;
begin
if not DBConnect(ServerName, DatabaseName, UserName, Password) then
Application.Terminate;
end;
求助请路过的大侠...
type
TPKGL = class(TRemoteDataModule, IPKGL)
........
private
{ Private declarations }
protected
{ Private declarations }
public
function DBConnect(aServerName, aDatabaseName, aUserName, aPassword: string): boolean;
{ Public declarations }
end;
function TPKGL.DBConnect(aServerName, aDatabaseName, aUserName, aPassword: string): boolean;
var
connStr: string;
begin
Result := True;
Connstr := 'Provider=SQLOLEDB.1;Password=' + aPassword + ';Persist Security Info=True;User ID=' + aUserName + ';Initial Catalog='+ aDatabaseName +';Data Source=' + aServerName;
try
if not ErpDBC.Connected then
begin
ErpDBC.ConnectionString := Connstr;
ErpDBC.DefaultDatabase := aDatabaseName;
ErpDBC.Open;
end;
except
messagebox(application.handle, '配置SQLSERVER数据库出错!', '提示!', 0);
Result := False;
end;
end;
同时在服务器端建一form窗口,却在form上无法调用数据模块DataModule的函数DBConnect,在form上已uses PKGL_RDB(数据模块),代码如下:
procedure TfrmMain.FormCreate(Sender: TObject);
var
serverName, databaseName, userName, password: string;
begin
if not DBConnect(ServerName, DatabaseName, UserName, Password) then
Application.Terminate;
end;
求助请路过的大侠...