davep
01-07-2003, 09:57 AM
How can I deploy an application which has ADODC controls on some forms
I find that if the database is not in the same directory path as when the link was made I get an untrappable error, even if resetting the connectionstring is the first item in the form activate.
Robby
01-08-2003, 10:20 AM
Are you hard-coding the path?
davep
01-09-2003, 01:25 AM
I'm creating a variable containing App.path & filename
then using that variable in a connection string.
Of course the control has an initial value which was created
when the link was made during development, but I get the same error if I leave the connectionstring blank when I compile the code.
Robby
01-09-2003, 11:57 AM
When you deploy the DB, is it actually in the expected path?
If so, does that PC have Access and/or MDAC?
davep
01-10-2003, 02:24 AM
When I create the application the databases are in a subdirectory of the application directory and the ADODC controls have their connectionstrings set appropriately.
When the application is deployed the user may choose a different location for the application and of course the installer correctly creates the sub directories for the databases, but the installer cannot change the connection strings of the ADODC.
I tried to write code to update the ADODC connectionstring as soon as the application is opened, but as soon as the control is referenced an untrappable error is thrown because it recognises that the database cannot be found, and I cannot therefore re-link it.
I thought perhaps that by making enable=false I would be able to change the connectstring without it first checking the current connectstring, but that dosn't work.
I can create the controls at run time, but that is a long work around, as I have a lot of ADODC's, and still has some quirks.
Robby
01-10-2003, 10:01 AM
Why not establish the connection only when the form is loaded, not when the program is loaded.
davep
01-13-2003, 01:31 AM
As far as I can see, the only way to create the connection when the form loads is to create the whole control (which I am now doing) but this seems a very poor workaround.
Surely the designers of VB must realise that anything connected to an external file could change at deployment time.
Machaira
01-13-2003, 07:28 AM
Originally posted by davep
As far as I can see, the only way to create the connection when the form loads is to create the whole control (which I am now doing) but this seems a very poor workaround.
Surely the designers of VB must realise that anything connected to an external file could change at deployment time.
They did, that's why they created the data objects which you create and manipulate with code. The data controls are very restricted as you've found out. Have you tried leaving the ConnectionString and other relevant properties blank and setting them at run-time?
davep
01-13-2003, 07:50 AM
Yes I've tried leaving them blank, but as soon as you refer to them at run time, in order to change the connection string, an error is thrown, which is not VB trappable, because the control cannot find it's data
Thinker
01-13-2003, 09:20 AM
The error is probably because you have the datacontrol bound to
other controls. If you are going to do this at run-time, you will
probably have to bind all the other controls at run-time too. As
Machaira already pointed out, the datacontrols are very limited
and to do anything serious, one is much better off coding their
own data access objects.