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 36045
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...
|
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...
|
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...
| |
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. ...
|
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...
|
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>...
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
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...
| |
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
| |