Solved

How to change server in connectionstring in vb.Net windows application

Posted on 2010-11-15
2
354 Views
Last Modified: 2012-05-10
I am new in vb.net and created a small windows application. In this app I created 4-5 datasets, and 2-3 connection in code where coded the connectionstring.
Now I want to send this app to client where it would connect to another server. Let me know the best way to change all connections to new server.
0
Comment
Question by:subhashpunia
2 Comments
 
LVL 18

Expert Comment

by:Dennis Aries
ID: 34135212
In your project, add a config-file.

Use the configfile to store the needed information.
The single-paged http://www.codeproject.com/KB/dotnet/config.aspx shows a very easy example. The page is for c#, but it will not be too hard to convert it to vb.net

You could even watch http://www.youtube.com/watch?v=zp7oyrfdnL4. Some people put everything on youtube ;)
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 34163423
The easier approach is to use the Settings tab on Project Properties. Just add a setting and set its value. Later, you can either change the value in VS or using a text editor. You would then use this setting in code and wont need to change the code if the connectionstring changes. For example

Dim dbcon as new SqlConnection(My.Settings.MyConnectionString)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now