Hello,
I try to check if my connection is connected. I have a Create-procedure where data from the database needed:
procedure TForm_LogIn.WebFormCreate(Sender: TObject);
begin
if Data_Module.xConnection_connect then begin
Data_Module.Get_Sprache;
Label_LoginTitel.DataSource:=Data_Module.DSC_Sprache;
Label_LoginTitel.DataField:='login_Titel';
Label_LogInUser.DataSource:=Data_Module.DSC_Sprache;
Label_LogInUser.DataField:='login_lable_username';
Label_LogInPasswort.DataSource:=Data_Module.DSC_Sprache;
Label_LogInPasswort.DataField:='login_label_passwort';
end;
end;
The function Data_Module.xConnection_connect felivers a boolean:
function TData_Module.xConnection_connect: boolean;
var
ABlick: TDateTime;
TimeOut: boolean;
procedure OnConnect;
begin
Result:= true;
end;
procedure OnError(Error: TXDataWebConnectionError);
begin
Result:= false;
ShowMessage('XData server connection failed with error: ' +
Error.ErrorMessage);
end;
begin
Result:= false;
if xConnection.Connected then begin
Result:= true;
end
else begin
xConnection.Open(@OnConnect, @OnError);
ABlick:= now();
TimeOut:= false;
while (TimeOut=false) and (Result=false) do begin
if (now()-ABlick > 0.00005) then
TimeOut:= true;
end;
end;
end;
But that way of working does not work. It seems, that the Create-Procedure does not wait for the result of the Data_Module.xConnection_connect function.
In TMS WebCore how can I wait a few secounds for the result?
Thanks Patrick