473,403 Members | 2,183 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,403 software developers and data experts.

App.config \ becomes \\

122 100+
I am trying to read my database name from the app.config file in C#

in the app.config it is stored as
Expand|Select|Wrap|Line Numbers
  1. <add key="DataBaseServer" value="Q-x\x"/>
  2.  
but when i say
Expand|Select|Wrap|Line Numbers
  1. _ServerName = ConfigurationManager.AppSettings.Get("DataBaseServer");
  2.  
it comes out as

"Q-x\\x" which of course causes my connection string i am building to fail due to the double \

how can i fix this so that it comes out with only one slash???

Appreciate the help!!
Nov 6 '08 #1
2 2319
Plater
7,872 Expert 4TB
Where are you seeing that double slash?
I bet if you printed the value out to the console window (which is available to you in debug mode under the title of "Output") that there is only one slash

I am assuming that "Q-x\x" is a madeup name, since I don't believe that is a valid servername? Hmm well maybe it is, but pretty sure the - is not allowed in server names, only _
Nov 6 '08 #2
nateraaaa
663 Expert 512MB
You could also do a string.Replace on the string that is returned with the \\ and replace \\ with \.

Nathan
Nov 6 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Al | last post by:
I use my assembly from asp and I need to config the dll from config file. What is the better way to do this? I don't want to hardcode file path in my dll (because...
1
by: win2kcowboy | last post by:
Using VS2003, ASP.NET 1.1 Is it possible to secure files normally placed as attachments (such as word docs etc.) and often placed in attachment directories within your web application, using...
22
by: Daniel Billingsley | last post by:
Ok, I wanted to ask this separate from nospam's ridiculous thread in hopes it could get some honest attention. VB6 had a some simple and fast mechanisms for retrieving values from basic text...
7
by: Dan | last post by:
I am trying to add a definition for ConnString to web.config as follows (VB.NET STD 2003) <configuration> <system.web> .......... <appsettings> <add key="ConnString" value="C:\test\test.mdb"...
3
by: Ron L | last post by:
I have an application that I am working on with 2 other developers. The applciation uses Remoting for our calls to SQL Server. We have been developing and testing against our development machines...
20
by: tomerfiliba | last post by:
hey i've been seeing lots of config-file-readers for python. be it ConfigObj (http://www.voidspace.org.uk/python/configobj.html) or the like. seems like a trend to me. i came to this conclusion...
2
by: hazz | last post by:
With this code, the config file(listed below) opens initially into the datagrid display with only a plus sign '+'. On clicking that, it becomes expanded to; - appsettings add When I click on...
10
by: Ryan | last post by:
I've created a custom configuration section that inherits (naturally) from System.Configuration.ConfigurationSection. The configuration section is working 99% fine, however I keep coming across a...
0
by: davemills81 | last post by:
Hi, Does anyone know how to update the user or application settings of a dll after building? The problem I have is? I have recently developed a service in C# that attaches references a dll. ...
4
by: =?Utf-8?B?Znc=?= | last post by:
Is there a way to config a asp.net app subdir's web.config so that the sub dir becomes a new IIS application in Visual Studio 2005? I need this because the authentication mode for the subdir is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
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...
0
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...

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.