How to Change Connection String of VB.NET Project at Design Time

One of the problems that a beginner encounter when there is a project uploaded here, is they do not know on how to change the connection string that points to the correct database location. This is true with MS Access and even with SQL Server. Some programmers don’t add a code that will automatically change the location of the database just in case it will be ported in other machine.

Here’s an example of MS Access connection string that cannot be used in other machine.

C:\Files\Data.mdb

If the source code is extracted on different folder then the project will not run.

Here’s an example of SQL Server that needs to be modified if run on other machine.

Data Source=My-PC\SQLEXPRESS;Initial Catalog=SalesReport;Integrated Security=True

If the name of the computer is not “My-PC” and the SQL Server instance is not “SQLEXPRESS”, then the project will not run.

The following is a tutorial on how to change the connection string of any project

clip_image002

Double click My Project.

image

Click on Settings and change the connection string on the “Value” column.

Comments

Submitted byAnonymous (not verified)on Wed, 03/09/2011 - 21:19

thanks for u're great advice.it helped me a lot

gud day! on library system, i attach the dbase and change the connectin string but still an error occured on the line on the modfunction: With conn If .State = ConnectionState.Open Then .Close() .Open() End With error is: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may caused by the fact that under the default settings SQL Server 2005 does not allow remote connections. (provider: SQL Network Interfaces, error: 26 – error locating Server / Instance Specified) please help!!! thanks!!!
Submitted byrusty (not verified)on Fri, 03/23/2012 - 21:14

yah.. i have the same problem to the error is A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) plss help us...
Submitted byAnonymous (not verified)on Sat, 03/24/2012 - 12:49

yeah its true
Submitted byAnonymous (not verified)on Sat, 05/11/2013 - 22:43

Hi sir. on library system, i attach the dbase and change the connecting string but still an error occured on the line on the modfunction: With conn If .State = ConnectionState.Open Then .Close() .Open() End With error is: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) please help!!! thanks!!! reply
Submitted bytelwah (not verified)on Mon, 08/19/2013 - 15:01

The other way is putting the connection string in ini file as parameter . So, any changes can be done from the ini file. I am using this method since I have started programming.
Submitted byriel.palmaon Mon, 12/02/2013 - 16:01

what would i do,,,the program that i downloaded was not working someone can help me :C

Add new comment