473,326 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Read Configuration

Hi All

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

<configuration>
<appSettings>
<add key="Desvio" value="652825616" />
<add key="MargenString" value="10" />
</appSettings>
</configuration>
Could somebody give and example of how to do it ?
Thanks in advance

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


System.Configuration.ConfigurationSettings.AppSett ings("Desvio")
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.Configuration.ConfigurationSettings.AppSett ings("Desvio")

Thanks for your reply.

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

I did:

Dim ConnectionString As String
Dim MargenString As String
Dim Desvio As String

Desvio = System.Configuration.ConfigurationSettings.AppSett ings("Desvio")
System.Console.WriteLine(Desvio)

MargenString =
System.Configuration.ConfigurationSettings.AppSett ings("MargenString")
System.Console.WriteLine(MargenString)

ConnectionString =
System.Configuration.ConfigurationSettings.AppSett ings("ConnectionString")
System.Console.WriteLine(ConnectionString)

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

and in config file I've:

<configuration>
<appSettings>
<add key="Desvio" value="652825616" />
<add key="MargenString" value="10" />
</appSettings>
</configuration>

But when I run my application I see:

---------
C:\tmp1>.\pruebaSQL.exe
Network Library=DBMSSOCN;Data Source=localhost;Initial atalog=segex;User
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.Configuration.ConfigurationSettings

Private Sub AppConfig

Dim Desvio,MargenString as String
Desvio = AppSettings("Desvio")
MargenString = AppSettings("MargenString")

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**************@TK2MSFTNGP14.phx.gbl...
Mattias Sjögren wrote:
Could somebody give and example of how to do it ?

System.Configuration.ConfigurationSettings.AppSett ings("Desvio")

Thanks for your reply.

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

I did:

Dim ConnectionString As String
Dim MargenString As String
Dim Desvio As String

Desvio = System.Configuration.ConfigurationSettings.AppSett ings("Desvio")
System.Console.WriteLine(Desvio)

MargenString =
System.Configuration.ConfigurationSettings.AppSett ings("MargenString")
System.Console.WriteLine(MargenString)

ConnectionString =
System.Configuration.ConfigurationSettings.AppSett ings("ConnectionString")
System.Console.WriteLine(ConnectionString)

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

and in config file I've:

<configuration>
<appSettings>
<add key="Desvio" value="652825616" />
<add key="MargenString" value="10" />
</appSettings>
</configuration>

But when I run my application I see:

---------
C:\tmp1>.\pruebaSQL.exe
Network Library=DBMSSOCN;Data Source=localhost;Initial atalog=segex;User
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
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; ...
5
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...
4
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: ...
3
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...
9
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...
1
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...
3
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...
2
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...
1
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...
5
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.