Solved

Problem with an inherited form

Posted on 2006-10-25
3
213 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
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, f…

863 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

21 Experts available now in Live!

Get 1:1 Help Now