Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Simple question

Reply
 
Old 05-29-2008   #1 (permalink)
Phil Hunt


 
 

Simple question

What is the significance of and @ prefix of a string. I see it mostly used
in a SQL statement .

Thanks



My System SpecsSystem Spec
Old 05-29-2008   #2 (permalink)
Jack Jackson


 
 

Re: Simple question

"@" has no general significance in a string.

In SQL statements, some data providers use "@" to indicate a
parameter. Using parameters rather than putting the values directly
in the SQL statement has several advantages, including automatic data
type conversion, prevention of SQL injection attacks and the ability
for the backend to calculate the execution plan once for multiple uses
of the statement.

On Thu, 29 May 2008 11:11:40 -0400, "Phil Hunt" <aaa@xxxxxx> wrote:
Quote:

>What is the significance of and @ prefix of a string. I see it mostly used
>in a SQL statement .
>
>Thanks
>
My System SpecsSystem Spec
Old 05-29-2008   #3 (permalink)
Phil Hunt


 
 

Re: Simple question

I understand what you are saying.
But maybe I should give an example right out of a book I am reading.

In C# :
String strConn = @"Data Source=.\SQLExpress;" +
"Initial Catalog=Northwind"

The @ sign is not insdei the string. I cannot find any explanation anywhere
what this means.

TIA

"Jack Jackson" <jjackson@xxxxxx> wrote in message
news:vo0u34hm92ubmss00bcfvvnk8hvnkuqaov@xxxxxx
Quote:

> "@" has no general significance in a string.
>
> In SQL statements, some data providers use "@" to indicate a
> parameter. Using parameters rather than putting the values directly
> in the SQL statement has several advantages, including automatic data
> type conversion, prevention of SQL injection attacks and the ability
> for the backend to calculate the execution plan once for multiple uses
> of the statement.
>
> On Thu, 29 May 2008 11:11:40 -0400, "Phil Hunt" <aaa@xxxxxx> wrote:
>
Quote:

>>What is the significance of and @ prefix of a string. I see it mostly used
>>in a SQL statement .
>>
>>Thanks
>>

My System SpecsSystem Spec
Old 05-29-2008   #4 (permalink)
Phil Hunt


 
 

Re: Simple question

Now I think about it. It may something to do with the escaple character \

Right ?

"Phil Hunt" <aaa@xxxxxx> wrote in message
news:uPbh%23AdwIHA.5620@xxxxxx
Quote:

>I understand what you are saying.
> But maybe I should give an example right out of a book I am reading.
>
> In C# :
> String strConn = @"Data Source=.\SQLExpress;" +
> "Initial Catalog=Northwind"
>
> The @ sign is not insdei the string. I cannot find any explanation
> anywhere what this means.
>
> TIA
>
> "Jack Jackson" <jjackson@xxxxxx> wrote in message
> news:vo0u34hm92ubmss00bcfvvnk8hvnkuqaov@xxxxxx
Quote:

>> "@" has no general significance in a string.
>>
>> In SQL statements, some data providers use "@" to indicate a
>> parameter. Using parameters rather than putting the values directly
>> in the SQL statement has several advantages, including automatic data
>> type conversion, prevention of SQL injection attacks and the ability
>> for the backend to calculate the execution plan once for multiple uses
>> of the statement.
>>
>> On Thu, 29 May 2008 11:11:40 -0400, "Phil Hunt" <aaa@xxxxxx> wrote:
>>
Quote:

>>>What is the significance of and @ prefix of a string. I see it mostly
>>>used
>>>in a SQL statement .
>>>
>>>Thanks
>>>
>
>

My System SpecsSystem Spec
Old 05-29-2008   #5 (permalink)
Jigar Mehta


 
 

Re: Simple question

Hi Phil,

That is because if you dont use @, you have to use \\ to express \ inside
a string..

So, if you dont use @,
String strConn = "Data Source=.\\SQLExpress;Initial Catalog=Northwind"

and if you use @,
String strConn = @"Data Source=.\SQLExpress;Initial Catalog=Northwind"

Look at MSDN for more information,

Jigar Mehta
Quote:

> I understand what you are saying.
> But maybe I should give an example right out of a book I am reading.
> In C# :
> String strConn = @"Data Source=.\SQLExpress;" +
> "Initial Catalog=Northwind"
> The @ sign is not insdei the string. I cannot find any explanation
> anywhere what this means.
>
> TIA
>
> "Jack Jackson" <jjackson@xxxxxx> wrote in message
> news:vo0u34hm92ubmss00bcfvvnk8hvnkuqaov@xxxxxx
>
Quote:

>> "@" has no general significance in a string.
>>
>> In SQL statements, some data providers use "@" to indicate a
>> parameter. Using parameters rather than putting the values directly
>> in the SQL statement has several advantages, including automatic data
>> type conversion, prevention of SQL injection attacks and the ability
>> for the backend to calculate the execution plan once for multiple
>> uses of the statement.
>>
>> On Thu, 29 May 2008 11:11:40 -0400, "Phil Hunt" <aaa@xxxxxx> wrote:
>>
Quote:

>>> What is the significance of and @ prefix of a string. I see it
>>> mostly used in a SQL statement .
>>>
>>> Thanks
>>>

My System SpecsSystem Spec
Old 05-29-2008   #6 (permalink)
Jon Skeet [C# MVP]


 
 

Re: Simple question

Phil Hunt <aaa@xxxxxx> wrote:
Quote:

> I understand what you are saying.
> But maybe I should give an example right out of a book I am reading.
>
> In C# :
> String strConn = @"Data Source=.\SQLExpress;" +
> "Initial Catalog=Northwind"
>
> The @ sign is not insdei the string. I cannot find any explanation anywhere
> what this means.
It's a verbatim string literal:

http://pobox.com/~skeet/csharp/strings.html

--
Jon Skeet - <skeet@xxxxxx>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Simple Question Vista General
simple question... really! Vista General
Simple Question? Vista General
a simple question Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46