Solved

Problem with an inherited form

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

Industry Leaders: 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

Suggested Solutions

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

749 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