Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

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

Avatar of EYoung
EYoungFlag for United States of America asked on
Visual Basic.NET
14 Comments1 Solution565 ViewsLast Modified:
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,