473,796 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Read Configuration

Hi All

I'm totally new to vbasic net and need to get values from a config files
in the way:

<configuratio n>
<appSettings>
<add key="Desvio" value="65282561 6" />
<add key="MargenStri ng" value="10" />
</appSettings>
</configuration>
Could somebody give and example of how to do it ?
Thanks in advance

X
Nov 21 '05 #1
3 1474
Could somebody give and example of how to do it ?


System.Configur ation.Configura tionSettings.Ap pSettings("Desv io")
Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 21 '05 #2
Mattias Sjögren wrote:
Could somebody give and example of how to do it ?

System.Configur ation.Configura tionSettings.Ap pSettings("Desv io")

Thanks for your reply.

I did in that way but it didn't worked and I'm going to be crazy !>..

I did:

Dim ConnectionStrin g As String
Dim MargenString As String
Dim Desvio As String

Desvio = System.Configur ation.Configura tionSettings.Ap pSettings("Desv io")
System.Console. WriteLine(Desvi o)

MargenString =
System.Configur ation.Configura tionSettings.Ap pSettings("Marg enString")
System.Console. WriteLine(Marge nString)

ConnectionStrin g =
System.Configur ation.Configura tionSettings.Ap pSettings("Conn ectionString")
System.Console. WriteLine(Conne ctionString)

--------------

and in config file I've:

<configuratio n>
<appSettings>
<add key="Desvio" value="65282561 6" />
<add key="MargenStri ng" value="10" />
</appSettings>
</configuration>

But when I run my application I see:

---------
C:\tmp1>.\prueb aSQL.exe
Network Library=DBMSSOC N;Data Source=localhos t;Initial atalog=segex;Us er
ID=sa;Password= sa
----------------
Program showed me the string of a parameter I deleted from config file
and didn't show me exsitent parameters !!!

How is posible ? Am I doing something wrong ? Is there a kind of cache
that keeps data ?

Thanks in advance

X

Nov 21 '05 #3
This 'should' work! Personally I like to import the classes to reduce coding
and make it more manageable BUT it makes no difference to the operation of
the code.

Imports System.Configur ation.Configura tionSettings

Private Sub AppConfig

Dim Desvio,MargenSt ring as String
Desvio = AppSettings("De svio")
MargenString = AppSettings("Ma rgenString")

End Sub

I wonder if you have edited the correct app.config file. You might want to
check in the IDE AFTER you have built your project. Select to view all files
and review the contents of the .exe.config file in your bin subdir.

HTH, Phil
"Cacho" <jl****@manresa .net> wrote in message
news:u8******** ******@TK2MSFTN GP14.phx.gbl...
Mattias Sjögren wrote:
Could somebody give and example of how to do it ?

System.Configur ation.Configura tionSettings.Ap pSettings("Desv io")

Thanks for your reply.

I did in that way but it didn't worked and I'm going to be crazy !>..

I did:

Dim ConnectionStrin g As String
Dim MargenString As String
Dim Desvio As String

Desvio = System.Configur ation.Configura tionSettings.Ap pSettings("Desv io")
System.Console. WriteLine(Desvi o)

MargenString =
System.Configur ation.Configura tionSettings.Ap pSettings("Marg enString")
System.Console. WriteLine(Marge nString)

ConnectionStrin g =
System.Configur ation.Configura tionSettings.Ap pSettings("Conn ectionString")
System.Console. WriteLine(Conne ctionString)

--------------

and in config file I've:

<configuratio n>
<appSettings>
<add key="Desvio" value="65282561 6" />
<add key="MargenStri ng" value="10" />
</appSettings>
</configuration>

But when I run my application I see:

---------
C:\tmp1>.\prueb aSQL.exe
Network Library=DBMSSOC N;Data Source=localhos t;Initial atalog=segex;Us er
ID=sa;Password= sa
----------------
Program showed me the string of a parameter I deleted from config file and
didn't show me exsitent parameters !!!

How is posible ? Am I doing something wrong ? Is there a kind of cache
that keeps data ?

Thanks in advance

X

Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5362
by: vkrasner | last post by:
It works with VS2003 and does not in VS2005: in VS2003 : string sMyvalue = ConfigurationSettings.AppSettings; in VS2005 (does not work!!) string sMyvalue = ConfigurationManager.AppSettings; Anybody able to give me idea how-to read by C# element which I add to the machine.config into the new single section?
5
1675
by: Stephen Costanzo | last post by:
Looking back in the group, I figured out how to read from the appSettings section of the configuration file. I have default values for the application in the unlikely event that the user deletes the configuration file. My question is this: How do I write the defaults back out to the configuration file at run time? is this even possible? I understand that the System.Configuration API is read only so would I basically have to read in...
4
1893
by: Steve Enzer | last post by:
I need to use a configuration file to set the connection string for the ado data connector in my project, but I'm having trouble reading the config file. My config file contains the following: <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="ConnectionString" value="server=localhost;user id=root;password=pw;database=aceinventory;pooling=false"/>
3
15967
by: Brett Romero | last post by:
I'd like to use some of the techniques discussed here for reading a config file in .NET 2.0: http://msdn.microsoft.com/msdnmag/issues/06/06/ConfigureThis/default.aspx Here's my app.config content: <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections>
9
4274
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi. Is it programatically possible in VB.NET to read the contents of web.config's <customErrorselement? I looked at using ConfigurationSettings.AppSettings, but that doesn't work. I need to read the value of redirect from the error statusCode 404. My web.config looks like this: <customErrors mode="RemoteOnly" defaultRedirect="Error.aspx"> <error statusCode="404" redirect="Error404.aspx" /> </customErrors>
1
2654
by: Rajen | last post by:
I've a automatic configuration proxy (http://xxx.xxx.xxx.xxx/xyz.pac) which I use in the Internet explorer Lan Settings to access the net. How do I read a webpage by specifying this proxy in my PHP code. By the by, I'm using curl to read the remote webpage. I've tried the option curl_setopt($ch, CURLOPT_PROXY, 'http://xxx.xxx.xxx.xx/xyz.pac'); but didn't work.
3
1546
by: jamitwidme | last post by:
Hello. I am a novice programmer and have a question I have a configuration file(configuration.cfg) I read this from reading.py using ConfigParser When I use ConfigParser.get() function, it returns a string. I want to call a function that has the same name as the string from the configuration file. configuration.cfg
2
5350
by: =?Utf-8?B?c2lwcHl1Y29ubg==?= | last post by:
Hi Is there any way to Read an INIFile from a string or Stream instead of a physical file ??? I want to read the INIFile into a string then store in a db but when I read the string from the db or save string to the db I don't want to have to copy the string to a file to use the WritePrivateProfileString and GetPrivateProfileString. Is there a way around this instead of writing my own class to operate on a string or stream ???
1
3827
by: ajmerasunny | last post by:
Hi All, I have a java web application in which I need to read a configuration file(WebAgent.conf) that has the reference of another configuration file(SmHost.conf). I am placing both these configuration files in the <root-dir> of the application. I am specifying the path for WebAgent.conf as “/WebAgent.conf” in my AuthenticateUser java class and in WebAgent.conf, the reference to SmHost.conf is given as “/SmHost.conf”. I am copying...
5
9121
by: gr8Ashish | last post by:
hi all i am using a windows application as well as web application developed in visual studio 2010 beta 2 using .net framework 4 on windows xp/windows server 2008/windows7 i am able to read web.config file on system running windows XP sp2 but same is not read by windows 7 and windows server 2008 i installed my web application on iis 7 on said windows with .net 4 but it not read web.config by my windows application. ...
0
9673
marktang
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...
0
10003
tracyyun
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...
0
9050
agi2029
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...
1
7546
isladogs
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5440
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...
0
5569
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4115
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
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2924
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.