Jump to content
Ian Branch

All DB components on a form lose their connection to their datasource..

Recommended Posts

Hi Team,

Win 11, D11.3.1.

I experienced this a while ago, pretty sure I asked the question here, but I don't recall ifthere was a resolution.

Twice in the past week two different Apps have had their DB components lose their connection to their datasource.  As in the Datasource entry in the components is empty.  All of them.

I have had to reconnect all the components to their datasource.  Oh the pain!!

It isn't just one datasource either. There are a couple of datasources involved that get lost.

Has anybody else experienced this?

Does anybody have any suggestions as to what might be causing it?

 

Regards & TIA,

Ian

 

Edited by Ian Branch

Share this post


Link to post

tip: do the search in your "Profile" and try find it!

 

big tip: I think that you need just "created another project" and migrate your code/components to new forms (not complete old-Forms)!!! think about

Share this post


Link to post
3 minutes ago, Ian Branch said:

have had to reconnect all the components to their datasource.  Oh the pain!!

Version control that file and commit often. Then you can merge the changes or just go back to the old version of the dfm. At least this will save the pain of resetting those connections.

 

I do not experience the problem.

 

Share this post


Link to post

Tks P2k.  I went to my Profile but couldn't find any search functionality.

@Uwe Raabe  said - "This can also happen when the missing DataSource is not located at the same form/frame as the DB components and the IDE fails to open the datamodule (or wherever this datasource resides) for whatever reasons. I had similar experiences with actions located in a datamodule. If by any chance that datamodule shares its name with one of the IDE internal ones (including those in 3rd party modules) that can be the cause of breaking the linkage."

 

Question - If the Form was opened on its own, and not via the project, therefore the relevant datamodule is not present/loaded, would that cause the issue?

 

Ian

Edited by Ian Branch

Share this post


Link to post
1 minute ago, Ian Branch said:

Question - If the Form was opened on its own, and not via the project, therefore the relevant datamodule is not present, would that cause the issue?

only if you re-save it, I think! 

 

question: are you using "Automatic save" in tools options!

Edited by programmerdelphi2k
  • Like 1

Share this post


Link to post
Just now, programmerdelphi2k said:

only if you re-save it, I think!

That is most often the case.  Open just the form to make a quick edit and save it.

Perhaps I should stop that practice..  😉

Share this post


Link to post
1 minute ago, programmerdelphi2k said:

other tip: use a GitHub (or other) to control your versions, then, always you'll have old saves!

I do, but better I don't cause the issue to start with.

Share this post


Link to post

IDE automatically removes datalinks if datasource is unavailable. Version control to save you from the pain of restoring links and you've to open forms with the project loaded. Or just assign datalinks at runtime

Share this post


Link to post
13 hours ago, Fr0sT.Brutal said:

IDE automatically removes datalinks if datasource is unavailable.

It could at least warn you and ask you if it should remove the links....

Share this post


Link to post

That sounds easier as it is. In the DFM the links are stored as texts (the name of the linked component). When the DFM is loaded the names are resolved to the actual instance. So after loading the names don't exist anymore outside the instance. Later when the DFM is saved, the instance names are written to the DFM.

 

To achieve what you propose, each linked property needs a place to store the loaded name when the link cannot be resolved and restored when saved. Alas, this can get pretty tricky in the case when the link was not found and you want to deliberately remove it.

 

If we step back and ask for a simple warning without the option to keep the missing links, that may be much easier to implement.

Share this post


Link to post
On 4/21/2023 at 11:49 PM, Ian Branch said:

It could at least warn you and ask you if it should remove the links....

Yeah, just like it does with missing components and even their props

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×