473,386 Members | 1,674 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,386 software developers and data experts.

ConfigurationSettings.AppSettings["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=SOMESERVER\\SOMEINSTANCE;integrated
security=SSPI;database=NDD"/>
</appSettings>

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

string mySelectQuery = "SELECT * FROM sometable'";
string myConnectString = ConfigurationSettings.AppSettings["NDDbase"];

SqlCommand myCommand = new SqlCommand(mySelectQuery);
myCommand.Connection = new SqlConnection(myConnectString);
But when debugging, I see that myConnectString value always starts with
an @, like this:
@"Server=SOMESERVER\\SOMEINSTANCE;integrated
security=SSPI;database=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 1776
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********@gmail.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=SOMESERVER\\SOMEINSTANCE;integrated
security=SSPI;database=NDD"/>
</appSettings>

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

string mySelectQuery = "SELECT * FROM sometable'";
string myConnectString = ConfigurationSettings.AppSettings["NDDbase"];

SqlCommand myCommand = new SqlCommand(mySelectQuery);
myCommand.Connection = new SqlConnection(myConnectString);
But when debugging, I see that myConnectString value always starts with
an @, like this:
@"Server=SOMESERVER\\SOMEINSTANCE;integrated
security=SSPI;database=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\tworld" is hello backslash tworld
whereas
"hello\tworld" is hello tab world

thanks

la********@gmail.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********@gmail.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=SOMESERVER\\SOMEINSTANCE;integrated
security=SSPI;database=NDD"/>
</appSettings>

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

string mySelectQuery = "SELECT * FROM sometable'";
string myConnectString = ConfigurationSettings.AppSettings["NDDbase"];

SqlCommand myCommand = new SqlCommand(mySelectQuery);
myCommand.Connection = new SqlConnection(myConnectString);
But when debugging, I see that myConnectString value always starts with
an @, like this:
@"Server=SOMESERVER\\SOMEINSTANCE;integrated
security=SSPI;database=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
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
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...
14
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...
3
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...
6
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 ...
3
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...
8
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 =...
1
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...
1
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.