?
Solved

Problem with an inherited form

Posted on 2006-10-25
3
Medium Priority
?
218 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 21

Expert Comment

by:K V
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 375 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses
Course of the Month8 days, 7 hours left to enroll

764 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