473,811 Members | 3,096 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ConfigurationSe ttings.AppSetti ngs["value"] returns a string that starts with '@'

Hello

I'm trying to use a connection string stored in web.config

here is the web.config part

<appSettings>
<add key="NDDbase"
value="Server=S OMESERVER\\SOME INSTANCE;integr ated
security=SSPI;d atabase=NDD"/>
</appSettings>

and from code I'm trying to access it like this:

string mySelectQuery = "SELECT * FROM sometable'";
string myConnectString = ConfigurationSe ttings.AppSetti ngs["NDDbase"];

SqlCommand myCommand = new SqlCommand(mySe lectQuery);
myCommand.Conne ction = new SqlConnection(m yConnectString) ;
But when debugging, I see that myConnectString value always starts with
an @, like this:
@"Server=SOMESE RVER\\SOMEINSTA NCE;integrated
security=SSPI;d atabase=NDD"

is this normal? I could parse the string and remove the at-sign but I
suppose is there for a reason. This makes the SqlConnection to not
open, as it is not initialized properly.

help me and write me some suggestions please, thanks =)

Regards
Laura Lucas

Jul 24 '06 #1
2 1796
now that I look at it, the at-sign is not part of the string, look at
this picture:

http://i7.tinypic.com/20tgj08.jpg

weird, what does it mean?
la********@gmai l.com wrote:
Hello

I'm trying to use a connection string stored in web.config

here is the web.config part

<appSettings>
<add key="NDDbase"
value="Server=S OMESERVER\\SOME INSTANCE;integr ated
security=SSPI;d atabase=NDD"/>
</appSettings>

and from code I'm trying to access it like this:

string mySelectQuery = "SELECT * FROM sometable'";
string myConnectString = ConfigurationSe ttings.AppSetti ngs["NDDbase"];

SqlCommand myCommand = new SqlCommand(mySe lectQuery);
myCommand.Conne ction = new SqlConnection(m yConnectString) ;
But when debugging, I see that myConnectString value always starts with
an @, like this:
@"Server=SOMESE RVER\\SOMEINSTA NCE;integrated
security=SSPI;d atabase=NDD"

is this normal? I could parse the string and remove the at-sign but I
suppose is there for a reason. This makes the SqlConnection to not
open, as it is not initialized properly.

help me and write me some suggestions please, thanks =)

Regards
Laura Lucas
Jul 24 '06 #2
the answer:

It means that any backslash characters displayed aren't used for escape
purposes. For instance:

@"hello\twor ld" is hello backslash tworld
whereas
"hello\twor ld" is hello tab world

thanks

la********@gmai l.com wrote:
now that I look at it, the at-sign is not part of the string, look at
this picture:

http://i7.tinypic.com/20tgj08.jpg

weird, what does it mean?
la********@gmai l.com wrote:
Hello

I'm trying to use a connection string stored in web.config

here is the web.config part

<appSettings>
<add key="NDDbase"
value="Server=S OMESERVER\\SOME INSTANCE;integr ated
security=SSPI;d atabase=NDD"/>
</appSettings>

and from code I'm trying to access it like this:

string mySelectQuery = "SELECT * FROM sometable'";
string myConnectString = ConfigurationSe ttings.AppSetti ngs["NDDbase"];

SqlCommand myCommand = new SqlCommand(mySe lectQuery);
myCommand.Conne ction = new SqlConnection(m yConnectString) ;
But when debugging, I see that myConnectString value always starts with
an @, like this:
@"Server=SOMESE RVER\\SOMEINSTA NCE;integrated
security=SSPI;d atabase=NDD"

is this normal? I could parse the string and remove the at-sign but I
suppose is there for a reason. This makes the SqlConnection to not
open, as it is not initialized properly.

help me and write me some suggestions please, thanks =)

Regards
Laura Lucas
Jul 24 '06 #3

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

Similar topics

1
10487
by: Grantsss | last post by:
Help! Ever since I have upgraded to .Net 2003, my config gets deleted when I run the following line ConfigurationSettings.AppSettings.Get("value")
5
20879
by: Derrick | last post by:
I have a C# console app, MyApp, and am placing an application config file in the same debug dir as MyApp.exe. I have named the file MyApp.config, and MyApp.exe.config. I cannot read the <appSettings> entries in the file though, I get null back for properties. config file <configuration> <appSettings> <add key="mySetting" value="hello_world" /> ....
14
5925
by: dale zhang | last post by:
Hi groups, Can anyone give me the equivalent C# sharp code for this VB.ET code, :: VB.NET :: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles MyBase.Load 'This event routine in the loginCheck user control fires when the
3
4936
by: Kevin Pedersen | last post by:
Hello, I am using an editable datagrid. After I save the changes the datagrid shows the old values. I've read the posts about the Page_Load and not binding the datagrid each time. The SQL that is being sent to the database is correct and the changes are eventually being made. If I refresh the page after the update then the new values appear. I noticed that when I put a breakpoint in my update handler everything works fine. When I take...
6
6129
by: Tony | last post by:
Dear All, When I run an example program on the http://www.dotnetjunkies.com/quickstart/util/srcview.aspx?path=/quickstart/aspplus/samples/webforms/data/datagrid1.src&file=VB\datagrid1.aspx&font=3 I received an error message: "The ConnectionString property has not been initialized.
3
2592
by: Arnold | last post by:
I am having problem loading the image from the database. It gives this error: "Invalid parameter used." This is my source code: Private abyt() As Byte Private fo As New OpenFileDialog Private sf As New SaveFileDialog Dim strCn As String = "Data Source=DATABASE\BARCA;" & _ "Initial Catalog=MIS;Integrated Security=SSPI" Dim cn As SqlConnection = New SqlConnection(strCn) Dim fs As IO.FileStream
8
2651
by: Mark | last post by:
Could someone provide me with details or a link on how the line of code executes underneath the hood? Assume it's executed in an ASP.NET application. string blah = ConfigurationSettings.AppSettings Once your application has called for the "foo" key once, how expensive is to call the same line again? My gut tells me that the CLR likely stores these values in memory in a string dictionary or similar. Looking up the value requires the...
1
13257
by: sandy.82in | last post by:
Hi I'm new to C# , I'm using VS2005 and .NET2.0 .Here is my issue i just developed a simple application with app.config , and a simple class library and following is my app.configfile <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="Setting1" value="Very" />
1
5823
by: Ken | last post by:
I'm currently using 1.1. Is there any way using the value of a ConfigurationSettings.AppSettings as a key of ConfigurationSettings.AppSettings.Tosting( )]? for example in web.config <add key="company" value="Hyundai" /> <add key="Hyundai" value="sonata" />
0
9734
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
9607
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10416
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10138
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
9215
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
7676
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
6897
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();...
2
3881
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3028
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.