473,800 Members | 2,476 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 1795
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
10486
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
5921
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
6126
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
13255
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
5821
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
9551
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
10251
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
10033
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
9085
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...
0
6811
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();...
0
5469
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
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
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
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.