Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

In the application that I have created, I need to pass the connection string value so that I can connect to a remote database server.

I don't want to hard code the values because the application will be permanently bound to a particular server.

I want to specify the connection string values in the XML file, but how should I retrieve it from the application?

Also can I write values from the application into the XML file?

Please help me!
Thank You.
Posted
Updated 23-Aug-10 8:35am
v3
Comments
Dalek Dave 23-Aug-10 5:41am    
Edited for Grammar and Syntax.

Ideally you should store your connection strings in the Application Settings File and retrieve them in your application by using My.Application.Settings.strConnection assuming your connection string is saved as strConnection. To set up your settings file, right click on your project in Solutions Explorer and select Properties. In the properties page that comes up select the Settings tab and you can save your connection string there. Under Type you can select Connection String.
Hope this helps
Happy Coding.
 
Share this answer
 
Ideally you should store your connection strings in the Application Settings File and retrieve them in your application by using My.Application.Settings.strConnection assuming your connection string is saved as strConnection. To set up your settings file, right click on your project in Solutions Explorer and select Properties. In the properties page that comes up select the Settings tab and you can save your connection string there. Under Type you can select Connection String.
Hope this helps
Happy Coding.
 
Share this answer
 
Ideally you should store your connection strings in the Application Settings File and retrieve them in your application by using My.Application.Settings.strConnection assuming your connection string is saved as strConnection . To set up your settings file, right click on your project in Solutions Explorer and select Properties. In the properties page that comes up select the Settings tab and you can save your connection string there. Under Type you can select Connection String.
Hope this helps
Happy Coding.
 
Share this answer
 
Comments
Dalek Dave 23-Aug-10 7:32am    
Why have you posted this three times?
What do you know about XML ? XML is just a string. You can read and write XML data quite trivially in VB.NET. You can use the XmlDocument class and the DOM to do that, that's probably the easiest and most widely documented way.
 
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