[EMAIL PROTECTED] wrote:
It says something about TStringList property Strings not being published...
You will get this error when loading a form with DB (related) components
with an Active=True property and the connection to the DB fails.
Doew anyone has any ideas how to solve that? I can remove the error, if
the dataset is opened while the component is 'loading', but then an
application will also silently close the database, without any error-
message?
I think an error mesage must be shown (in design mode always, in runtime
depending on the OnError handler)
In design mode it may not result in an exception, and the db should stay
closed. In runtime an exception is OK unless handled on the OnError
The TDataset, TDatabase and TTransaction components can't show a
messagedialog, since they are part of the FCL.
So I can suppress the exception. But then you'll never know why it's
impossible to set the active property to true, when you are in design
time.
Maybe that you can change it on the lazarus side: in the except-block,
take care of the EDatabaseError exceptions. (ie: show the message, and
don't reraise it)
In the attachment there is a patch which does this. Maybe that there
should be an extra try-block around the reader.ReadRootComponent, because
now the DoFinishReading isn't called. (what does that do?)
But the result of the patch is nice - with a messagebox with the DB-error
as a result.
But i'm not that into jitforms - so I could have missed something...
Problem with this solution is that is breaks the loading chain.
I propose a more Delphi compatible way, but this need some changes in
the DB classes. Please note that this is untested code, so I don't know
if it even compiles.
I see no reason to keep TDataset.InternalHandleException abstract, but
if there is a reason the code can be moved to TDBDataset.
Also I saw no reason why a TDatabase shouldnt have a similar
InternalHandleException, so I added it. This way, both TDataset and
TDatabase are handled the same way (unlike Delphi)
Marc
*** /usr/src/fpc/fcl/db/database.inc 2005-05-27 19:43:46.000000000 +0200
--- database.inc 2005-10-17 23:57:06.000000000 +0200
***************
*** 31,46 ****
begin
If Connected Then
DatabaseError(SConnected,Self);
end;
! procedure TDataBase.Loaded;
begin
inherited;
! if FOpenAfterRead then
! SetConnected(true);
end;
procedure TDataBase.SetConnected (Value : boolean);
begin
--- 31,60 ----
begin
If Connected Then
DatabaseError(SConnected,Self);
end;
! procedure TDataBase.InternalHandleException;
! begin
! if Assigned(Classes.ApplicationHandleException) then
! Classes.ApplicationHandleException(ExceptObject)
! else
! ShowException(ExceptObject, ExceptAddr);
! end;
+
+ procedure TDataBase.Loaded;
begin
inherited;
! try
! if FOpenAfterRead then SetConnected(true);
! except
! if csDesigning in Componentstate then
! InternalHandleException
! else
! raise;
! end;
end;
procedure TDataBase.SetConnected (Value : boolean);
begin
*** /usr/src/fpc/fcl/db/dataset.inc 2005-05-27 19:43:46.000000000 +0200
--- dataset.inc 2005-10-17 23:56:59.000000000 +0200
***************
*** 641,650 ****
--- 641,658 ----
begin
//!! To be implemented
end;
+ procedure TDataset.InternalHandleException;
+ begin
+ if Assigned(Classes.ApplicationHandleException) then
+ Classes.ApplicationHandleException(ExceptObject)
+ else
+ ShowException(ExceptObject, ExceptAddr);
+ end;
+
Procedure TDataset.InternalRefresh;
begin
//!! To be implemented
end;
***************
*** 701,711 ****
procedure TDataset.Loaded;
begin
inherited;
! if FOpenAfterRead then SetActive(true);
end;
procedure TDataSet.RecalcBufListSize;
--- 709,726 ----
procedure TDataset.Loaded;
begin
inherited;
! try
! if FOpenAfterRead then SetActive(true);
! except
! if csDesigning in Componentstate then
! InternalHandleException
! else
! raise;
! end;
end;
procedure TDataSet.RecalcBufListSize;
*** /usr/src/fpc/fcl/db/db.pp 2005-05-27 19:43:46.000000000 +0200
--- db.pp 2005-10-17 23:57:59.000000000 +0200
***************
*** 978,987 ****
--- 978,988 ----
function GetRecNo: Longint; virtual;
procedure InitFieldDefs; virtual;
procedure InitRecord(Buffer: PChar); virtual;
procedure InternalCancel; virtual;
procedure InternalEdit; virtual;
+ procedure InternalHandleException; virtual;
procedure InternalInsert; virtual;
procedure InternalRefresh; virtual;
procedure OpenCursor(InfoQuery: Boolean); virtual;
procedure RefreshInternalCalcFields(Buffer: PChar); virtual;
procedure RestoreState(const Value: TDataSetState);
***************
*** 1024,1034 ****
procedure InternalAddRecord(Buffer: Pointer; Append: Boolean); virtual;
abstract;
procedure InternalClose; virtual; abstract;
procedure InternalDelete; virtual; abstract;
procedure InternalFirst; virtual; abstract;
procedure InternalGotoBookmark(ABookmark: Pointer); virtual; abstract;
- procedure InternalHandleException; virtual; abstract;
procedure InternalInitFieldDefs; virtual; abstract;
procedure InternalInitRecord(Buffer: PChar); virtual; abstract;
procedure InternalLast; virtual; abstract;
procedure InternalOpen; virtual; abstract;
procedure InternalPost; virtual; abstract;
--- 1025,1034 ----
***************
*** 1346,1355 ****
--- 1346,1356 ----
procedure RemoveDataSets;
procedure RemoveTransactions;
protected
Procedure CheckConnected;
Procedure CheckDisConnected;
+ procedure InternalHandleException; virtual;
procedure Loaded; override;
procedure Notification(AComponent: TComponent; Operation: TOperation);
override;
Procedure DoInternalConnect; Virtual;Abstract;
Procedure DoInternalDisConnect; Virtual;Abstract;
public