在你设计期和运行期,它会通知服务器的。
procedure TSVR_CaiGou.RemoteDataModuleCreate(Sender: TObject);
var
i: integer;
begin
if frm_Main.ConnectStr = '' then
frm_Main.SetSysdbConnected(sysdb); //设置连接
Application.ProcessMessages;
for I := 0 to self.ComponentCount - 1 do
begin
if (self.Components is TDataSetProvider) then
TDataSetProvider(Components).BeforeUpdateRecord := DSP_CG_CLCGRK_MBeforeUpdateRecord;
Application.ProcessMessages;
end;
end;
procedure Tfrm_Main.SetSysdbConnected(sysdb: TADOConnection);
var
sysDbName: string;
sysSvName: string;
sysDbUser: string;
sysDbPsw: string;
IniFile: string;
MyIni: TIniFile;
begin
IniFile := ExtractFilePath(Application.ExeName) + SYSCONFIGFILE;
if not FileExists(IniFile) then
begin
MyIni := TIniFile.Create(IniFile);
MyIni.WriteString('Sysdb', PRMSYSSV, 'ServerPCName');
MyIni.WriteString('Sysdb', PRMSYSDB, 'DatabaseName');
MyIni.WriteString('Sysdb', PRMUSER, 'DataBaseUser');
MyIni.WriteString('Sysdb', PRMPSW, 'DataBasePSW');
MyIni.Free;
ShowMessage('ÇëÕýÈ·ÅäÖóÌÐòÎļþ: ' + #13 + IniFile);
end;
MyIni := TIniFile.Create(IniFile);
with MyINI do
begin
sysDbName := ReadString(SYSDBCNGLOCK, PRMSYSDB, 'JXERP');
sysSvName := ReadString(SYSDBCNGLOCK, PRMSYSSV, 'server');
sysDbUser := 'SA'; // ReadString(SYSDBCNGLOCK, PRMUSER, 'SA');
sysDbPsw := ''; // ReadString(SYSDBCNGLOCK, PRMPSW, '');
end;
ConnectStr := ' Provider=SQLOLEDB.1;Persist Security Info=False;User ID=' + sysDbUser +
';Password=' + sysDbPsw + ';Initial '
+ 'Catalog=' + sysDbName + ';Data Source=' + sysSvName
+ ';Locale Identifier=2052;Connect Timeout=60;Use Procedure for Prepare=1;'
+ 'Auto Translate=True;Packet Size=4096';
sysDB.connected := False;
sysDB.ConnectionString := ConnectStr;
try
sysDB.Connected := True;
except
ShowMessage('Êý¾Ý¿âÁ¬½Ó³ö´í!');
Halt(0);
end;
end;