Avatar of EYoung
Flag for United States of America

asked on 

Help with SQL Connection and command lines in multi-form VB 2008 Windows app?

I am new to VB 2008 but am experienced with VB6.  Recently I have been asked to develop a VB2008 Windows application that allows the users to maintain (Add, Change and Delete) records in three different tables  (TableA, TableB and TableC) within the same database (Purchasing_Module).

I have developed a VB2008 Windows application that has four forms and one Module.  The first form is the main form that has a menu that allows the users to click on which table they want to maintain.  The remaining three forms are for each of the three tables.  The Module contains commonly used variables defined as Public as I have done in in the past with VB6.

In VB6 I use to do the following:
   1.  Have a Module in which I would define the connection, command strings and other variables as Public.
   2.  Open the connection in the Main form and leave it open for the duration of the user's use of the application for each of the three table forms.  I only opened and closed the connection once.
   3.  Close the connection in the Main form's exit sub routine when the user exits the application.

In VB2008 I am not clear on how or where to accomplish these same things.  I don't want to open and close the SQL Connection each time the user Adds, Changes or Deletes records in each of the three tables as that traditionally would waste resources.

Can someone tell/show me what connection/command lines to put where?
   1.  What goes into the Module1.vb?
   2.  What goes into the startup form (Main.vb) and where do the Connection.Open and .Close lines go?
   3.  What goes into each three table form?

Thank you,
Visual Basic.NET

Avatar of undefined
Last Comment

8/22/2022 - Mon