Moving database programs between machines, in Visual Basic (or C#) .Net 2003

by Jeff Charles

Updated about 12/31/2004

Return to Home Page

 

I've been looking into the process of moving database programs some more, including the options on page 551 of the Visual Basic textbook (ISBN 0072512393 Advance Programming Using Visual Basic .Net by JCBradley and ACMillspaugh), and I've been experimenting.  I've found out some of the things that were keeping my programs from working before, when I moved them.

 

When I copied a VB .Net project from home, to a PC at Lakeland Community College, if I modified the connection string (in the connection's Properties window, ConnectionString property---or in the vb code), I had to remove the reference to my SQL Server instance '\vsdotnet', since the PCs at school don't have instance names for the SQL Server installations.  You can check the server name, and instance name (if any), in the VB Server Explorer after you expand the nodes under Servers, then under SQL Servers.  For example, my machine at home says 'antec2003\vsdotnet' because I used an instance name of vsdotnet when running setup of the MSDE SQL Server Desktop Engine.  But the machine I used at the lab at school just said a1046-05 -- the machine name.

 

I also had to adjust the server machine name, of course, and adjust the database file/path location in the ConnectionString.

 

I found I had to remember to do the following:

(1) make sure that the pubs or Northwind database is on the target machine

(2) make sure that there is a connection to the database set up in the VB Server Explorer (by the Connect to Database button, or by Tools->Connect to Database, or by using <New Connection...> under the Properties window)

(3) make sure the form's connection object's Properties show the correct ConnectionString (see page 551 of textbook), either specific or generic

(4) and don't forget to make sure SQL Server is running, in the SQL Server Service Manager.  On the machines in the lab it seems to be set up okay, to start automatically when the machine boots up.

 

In the Connection object's Properties window, for the ConnectionString property, you can modify it several ways: (1) edit the string in the field in the Properties window, after perhaps deleting the old value, or (2) choose an existing connection from the combo box's drop-down list, which has the same items as listed in the Server Explorer.  Or, (3) you can go in and edit the VB code directly, but this is probably riskier.  NOTE: If you modify the connection string using the Properties window ConnectionString field, VB will automatically update it in the program code for you, to keep them in sync.

 

The generic string mentioned on page 551-552 of the textbook worked okay, when I had other things right.

 

I also tried the Dynamic Properties mentioned on page 551 of the book, and that worked, too.

 

It doesn't seem to matter whether you move the files to the target machine and then alter the connection string, or vice versa, if, for example, you're using the generic connection string.

 

It seems to work to move/store files using various ways such as floppy, jump/thumb drive, the Lakeland p: drive, or email attachment.  But it did **NOT** work for me to try to RUN the program from the Lakeland p: drive!  I could move/store it using the p: drive, but then I had to copy the project over to somewhere on the machine's local c: drive before I could actually run it!

 

Return to top of page        Return to Home Page

Copyright © 2004 Jeffrey A. Charles; all rights reserved.