Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
So my problem over here is that, i have done back up on my sql database named 'SDP' then i have restored the sql backup file in another new PC. Now i would like to execute my vb.net program from the new PC. The problem i am facing is that the server name i have written in my codes are the server name of my previous PC("servernamePC1"). Now in the new PC, it has a new server name. Hence, how to set a universal connection path in vb.net to connect to my database.

The server name i have given down there is a sample server name not the actual server name. Assume that the server name("servernamePC1") is the first PC's server name. Now i have to connect to the database in a new pc with a different server name. Is that possible? or do i have to set a universal path??

What I have tried:

Dim con As New SqlConnection("server = servernamePC1; database=SDP; integrated security=SSPI")
Posted
Updated 24-Apr-19 11:58am
Comments
[no name] 17-Apr-19 15:18pm    
You can
a.) Put the server name into a configuration file
b.) Use only unnamed server instances which are always reachable with "localhost"

You can try 'localhost' as generic server name on local machine. Make sure SQL services listen to address 127.0.0.1
 
Share this answer
 
This is why you should always store your connection strings in your config file[^], as 0x01AA suggested in the comments. :)

You might be able to get away with setting up an alias[^] for the old server. But you would need to set that up on every computer where you application needs to run.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900