Solved

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

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 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

16 Experts available now in Live!

Get 1:1 Help Now