Problem with an inherited form
Posted on 2006-10-25
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.