Solved

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

Posted on 2010-11-15
2
356 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

773 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