Dirty User Control in Toolbox causes ConnectionString Failure?

G

Guest

Hello Everyone:

I used VB.NET 2003 Standard to create a User Control which I named
PersonControl and then overrode its OnLoad routine to use SQL commands to
populate its sub-controls.

When I tried to use the Form Designer to add my PersonControl to a form in
my application, I got the following error dialog box:
Title: Microsoft Development Environment
Text: The ConnectionString property has not been initialized.
Buttons: OK

After viewing the error dialog, I made two assumptions:
1) My DB connection didn’t go active until my application was running
2) The forms designer was, for some odd reason, invoking the OnLoad override
of my PersonControl which was doomed to fail since my DB connection was in
fact not initialized.

After making the two assumptions, I commented out the OnLoad override of my
PersonControl and tried adding it to my form via the toolbox once again as a
test, but I still got the error. With the OnLoad override commented out for
the PersonControl, I could not see any reason why adding it to a form would
cause the above mentioned dialog error.

It appears that a dirty/old copy of the PersonControl is presently lurking
around in my Toolbox and that I can’t replace it with a new one.

Can someone help answer the following questions for me?
1) Does the VB.NET forms designer automatically call the OnLoad function for
all controls when they are placed in a form being designed even though the
application is not yet running?
2) After you manage to populate your toolbox with a custom User Control, how
do you ensure that the control instance residing in your toolbox updates its
behavior whenever you change the source code used to generate that control?

Respectfully,

Shawn Eary
 
C

Cor Ligthert

Shawn,

In a good design there is in the UI no database "system.data" action.

You create it even in a user control.
Do you think that you are on the right track?

Why I tell this.
It is never interresting to spend time to help for a bad designs.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top