hi,
I tried , but was not solving the problem.
I made a small unit to save the IP Address in a txt file
and on datamodulebefore create event
load the ip from txt file.
Thank you very much for helping me.
procedure TFrmParam.BtnLoadClick(Sender: TObject);
var
TextFile : TStringList;
FileName : string;
begin
try
textFile := TStringList.Create;
try
FileName := Format('%sIPFile.txt',[GetHomePath]);
if FileExists(FileName) then
begin
textFile.LoadFromFile(FileName);
Memo1.Lines :=textfile;
end
else
begin
showMessage('File not exists, Create New File');
TextFile.Text := '0.0.0.0';
TextFile.SaveToFile(FileName);
end;
finally
textFile.Free;
end;
except
on E : Exception do ShowMessage('ClassError: '+e.ClassName+#13#13+'Message: '+e.Message);
end;
end;
procedure TFrmParam.BtnSaveClick(Sender: TObject);
var
TextFileS : TStringList;
FileName : string;
begin
try
textFileS := TStringList.Create;
try
if memo1.Text <> '' then
begin
FileName := Format('%sIPFile.txt',[GetHomePath]);
TextFileS.Text := Memo1.Text;
TextFileS.SaveToFile(FileName);
end;
finally
textFileS.Free;
end;
except
on E : Exception do ShowMessage('ClassError: '+e.ClassName+#13#13+'Message: '+e.Message);
end;
end;
procedure TDataModuleFDClient.DataModuleCreate(Sender: TObject);
var Lmemstream : Tmemorystream;
server : Tobject;
TextFile : TStringList;
FileName : string;
serverip : string;
begin
serverip :='0.0.0.0';
textFile := TStringList.Create;
try
FileName := Format('%sIPFile.txt',[GetHomePath]);
if FileExists(FileName) then
begin
textFile.LoadFromFile(FileName);
serverip :=textfile.Strings[0];
end;
finally
textFile.Free;
end;
SQLConnection1.Connected :=false;
sqlconnection1.params.values['HostName'] :=serverip;
SQLConnection1.Connected :=true;
end;