Using the visual studio.net text editor, I know how to
enter/change the "key/value" in the app.config file, for
example:
key="SqlConnect ion1.Connection String" value="data
source=Boomer;i nitial catalog=TimeDb; integrated
security=SSPI;p ersist security info=False;work station
id=BOOMER;packe t size=4096"
But I want to be able to change some values, (e.g. data
source string) in vb code programmaticall y at run time.
Can this be done? If so, how?
Thanks in advance for your help. 4 36077
Hello,
"jasiglam" <ju*********@ho tmail.com> schrieb: Using the visual studio.net text editor, I know how to enter/change the "key/value" in the app.config file, for example:
key="SqlConnect ion1.Connection String" value="data source=Boomer;i nitial catalog=TimeDb; integrated security=SSPI;p ersist security info=False;work station id=BOOMER;packe t size=4096"
But I want to be able to change some values, (e.g. data source string) in vb code programmaticall y at run time. Can this be done? If so, how?
You can do that using the XML classes contained in the framework.
Nevertheless the config file should not be modified by the application.
HTH,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET http://www.mvps.org/dotnet
Hi Jasiglam,
There's a help topic: Introduction to Dynamic Properties,
ms-help://MS.VSCC/MS.MSDNVS/vbcon/html/vboriintroducti ontoapplication setting
storage.htm
Unfortunately everywhere that it talks about changing the config items,
it says to open the file in an editor and type away!!
As it's an XML file, however, you should be able to read it in, change
it and write it back out again using an XMLDocument. I say "should" because
the file may be locked during execution - I don't know.
You should be aware that "app.config " is used when developing but your
program, "appFoo", say, will use "appFoo.exe.con fig".
If you are talking about a web app, changes to the config file cause the
web app to restart.
Good luck,
Fergus
You shouldn't actually be doing this, because app.config files are
application configuration, and not application preferences configuration,
but if you must, the XML classes (In the System.XML namespace) will help
you.
--
Happy to help,
-- Tom Spink
(th**********@n tlworld.com)
"Go down with your server" http://dotnetx.betasafe.com >> On The Mend
Please respond to the newsgroup,
so all can benefit
"jasiglam" <ju*********@ho tmail.com> wrote in message
news:00******** *************** *****@phx.gbl.. . Using the visual studio.net text editor, I know how to enter/change the "key/value" in the app.config file, for example:
key="SqlConnect ion1.Connection String" value="data source=Boomer;i nitial catalog=TimeDb; integrated security=SSPI;p ersist security info=False;work station id=BOOMER;packe t size=4096"
But I want to be able to change some values, (e.g. data source string) in vb code programmaticall y at run time. Can this be done? If so, how?
Thanks in advance for your help.
Thank you for your time and help. In my application, I
need to change the connection string to a database in SQL
Server based on the user's input. The purpose is to
regulate which user can access which table using SQL
Server's security mechanisms.
In VS Studio "Help", under "ADO.NET, connections", in a
document "Introducti on to ADO.NET Connection Design
Tools", in the section "Configurab le Connection
Properties", they suggested the following (see below),
which clearly indicates that changing the app.config file
by the program is possible.
If I don't use the app.config file to do this, do you have
any suggestions on how to programmaticall y change the
connection string? Note that this is a Windows app (not
Web-based) and I am using Visual Studio to generate the
adapter and connection objects for every form.
Thanks, again for your help.
(Quote from VS Help)
Configurable Connection Properties
In many applications, connection information cannot be
determined at design time. For example, in an application
that will be distributed to many different customers, you
might not be able to determine at design time the
connection information (such as the name of a server, a
user name, or a password).
Connection strings are therefore often specified as
dynamic properties. Because dynamic properties are stored
in a configuration file (and not compiled into the
application binary files), they can be changed without
having to recompile the application.
A typical strategy is to specify connection properties as
dynamic properties, provide a way (such as a Windows Form
or Web Form page) for users to specify the relevant
details, and then update the configuration file. The
dynamic-property mechanism built into the .NET Framework
automatically gets the values from the configuration file
when the property is read, and updates the file when the
value is updated. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: TK |
last post by:
What's the best way to edit web.config programmatically?
I want to have an aspx page as a GUI for web admins to modify the roll-base
security portion of the web.config(s) on a server.
please help.
TK
|
by: vadim |
last post by:
Hi,
Is there a .Net control available that allows to write into web.config file
appsettings section?
The idea is to create encrypted user name and password for database
connection and then use them from ASP.Net. The program that will create the
encrypted entries is a simple winform app.
ConfigurationSettings.appsettings allows to read web.config sections but how
|
by: Kevin Jackson |
last post by:
Is there a .NET framework call(s) or technique that allows one to
programmatically find the machine.config file.
|
by: Praveen Ramesh |
last post by:
Hi,
Is there any way to add the @Assembly reference to the aspx files
programmatically from inside a custom control (when it gets dropped on to
the page from the toolbox)?
I have a custom control - MyControl that implements an interface in another
custom assembly - InterfaceAssembly. When MyControl gets dropped on to the
page and run, it results in a "InterfaceAssembly not found" exception. I am
aware that this can be fixed by...
|
by: Codex Twin |
last post by:
Hello
apologies if this is the wrong newsgroup to be sending this to.
Basically, I have an ASP.NET application that I am trying to force to use a
proxy server settings. This can be done by accessing machine.config, but I
do not have access to the client machine.config machine.
Therefore every request made from this application must have these proxy
server settings. But I am having problems writing the code for this.
| |
by: TC |
last post by:
Hello All,
I have winforms app that accesses a webservice and the WSDL is referenced
dynamically.
I was wondering 2 things:
First, if one parses the .config file and changes the URL pointing to the
WSDL, I take it that these changes would not take effect until the user
closes and restarts the app, correct?
|
by: Andrew |
last post by:
I have ASP.NET 2.0 application. I'm running some initialization code in
Application_Start() in Global.asax. If this code fails I would like to
shutdown the application completely. Meaning no page, or an error page is
returned to the user. I've tried HostingEnvironment.InitiateShutdown() but
it's async and still returns a page to the user. According to msdn this
method is equivalent to ApplicationManager.ShutdownApplication()...
|
by: fcaico |
last post by:
I have a .NET 1.1 C# application that needs to connect to a custom web
service for authentication and system access. This web service uses a
custom SOAP header for security purposes.
In the past this has been a non issue because I simply registered a
SoapHeaderExtension in the application's App.Config file.
Now, however, we have need of using this C# client code in an assembly
which doesn't have access to an app.config file (long...
|
by: Andrew Jocelyn |
last post by:
Hi
How do I programmatically change (read/write) the values in this app.config
file at runtime? Specifically I want to change the client endpoint address
but it would be nice to change other values too. I thought this is what
ServiceHost is for but is seems way more complicated to use for what I'm
trying to do.
<system.serviceModel>
<bindings>
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |