I have just decided to solve the "Connection" problem when a MSSQL Database server is restarted, and the connection is dropped eternally.
The only solution so far has been to restart the program, not always so easy on server far-far away (and the problem must be detected).
The code below seems to be working fine, but if some skilled ADO person would look deeper into it and see any errors/problems or improvements with this code would be much appreciated!
Type TComponentHelper = class helper for TComponent Procedure Reconnect(AdoConn:TAdoConnection; ConnStr:String); end; procedure TComponentHelper.Reconnect(AdoConn: TAdoConnection; ConnStr: String); begin if Assigned(AdoConn) then begin FreeAndNil(AdoConn); AdoConn := TAdoConnection.Create(Self); AdoConn.ConnectionString := ConnStr; AdoConn.LoginPrompt := false; SetConnAdoComponent(Self,AdoConn); AdoConn.Open; end; end; procedure SetConnAdoComponent(aSrc:TComponent; var AdoConn:TAdoConnection); var Ctrl : TComponent; i : Integer; begin if (aSrc = Nil) then Exit; if (aSrc.ComponentCount <= 0) then Exit; for i:=0 to aSrc.ComponentCount-1 do begin Ctrl := aSrc.Components[i]; if (Ctrl is TAdoQuery) then TAdoQuery(Ctrl).Connection := AdoConn; if (Ctrl is TAdoTable) then TAdoTable(Ctrl).Connection := AdoConn; if (Ctrl is TAdoDataset) then TAdoDataset(Ctrl).Connection := AdoConn; end; end