Solved

Problem with an inherited form

Posted on 2006-10-25
3
212 Views
Last Modified: 2010-04-23
In Visual Studio, I have a created a form (I shall call it formA) that uses a global data connection which is created by the MDI form. I created another form (formB), which inherits from formA. When the application runs, all works fine. However, whenever I load up the project in Visual Studio (or after I rebuild the solution), I get an error when I open formB for editing ["ExecuteReader requires an open and available Connection..."].  I inserted a bit of code in formA, to check the state of the connection and, if connection was closed, display a log on window. When I open formB for editing, the log on window is displayed.

So it appears that when I open formB for editing, it is actually executing some of the code from formA. Does anyone know why this is and how I can avoid it? I intend to have several forms inherit from formA and I would not want to receive an error message from each one on loading the project.
0
Comment
Question by:Mart_dude
3 Comments
 
LVL 21

Expert Comment

by:theGhost_k8
ID: 17802719
well as formB is inherited from formA.. it must calling the constructor... oouch i mean New() function
check if u have not written anything in New() of A..
well could u post the code where does the error occur?
0
 
LVL 39

Accepted Solution

by:
appari earned 125 total points
ID: 17802877
Skip your checking of state of connection and other related code you intend to check at runtime  by checking designmode property.

add the following line before the code you want to excute at runtime.

if me.designmode then return
0
 

Author Comment

by:Mart_dude
ID: 17803081
I found the solution elsewhere just as appari partly gave the right answer .
By design, the form load routine of a base form will run when going to edit a form that inherits from it (I don't know what benefit this provides though). The solution is to put the code snippet offered by appari at the start of the routine that 'handles mybase.load' within the base form.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now