General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 28th, 2002, 07:20 PM
Nigorr Nigorr is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Brisbane, Australia
Posts: 78 Nigorr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 17
Question C# Newbie

I am simply trying to put a connection string in a constant so i don't have to write the connection string out 4-6 times. But it is not working!! How do I fix it?? It is ASP.Net, but it is a C# language problem that is why I posted it here.

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1009: Unrecognized escape sequence

Source Error:

Line 9: public class miniPassport
Line 10: {
Line 11: const string connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("\nigorr\db\test\miniPassport.mdb") & ";Persist Security Info=False;";
Line 12:
Line 13: [WebMethod(Description = "Method to Authenticate Users")]


Source File: \\genfs2\www20\nigorr\test\minipassport\minipasspo rt.asmx Line: 11

Reply With Quote
  #2  
Old April 29th, 2002, 03:24 AM
James Yang James Yang is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Atlanta, Georgia
Posts: 284 James Yang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 45 sec
Reputation Power: 17
Send a message via ICQ to James Yang
That is all correct Except where you have MapPath("blah

in c# and many other languages

char "\" in a string is a constant representing many "unrepresentable" characters such as new line

eg.
if you have
string aString = "hello\nworld";

when you display aString, you will see

hello
world

now to your problem.. there are two ways to overcome this.. one is for eveery \ replace it with \\ as \\ represents \

2nd way is to use @ sign

so

Server.MapPath(@"\nigorr\db\test\miniPassport.mdb")

@ sign ignors any \ being interpreted as a constant (escape sequence).

so
string aString @"hello\nworld";
will display

hello\nworld

hope this help
__________________
Regards,

James Yang
.NET Developer / Network Engineer
MCSE, MCDBA, MCSA, CCNA

http://www.yellowpin.com/
http://www.opentechsupport.com/

Reply With Quote
  #3  
Old April 29th, 2002, 06:31 PM
Nigorr Nigorr is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Brisbane, Australia
Posts: 78 Nigorr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 17
Thanks for that, glad you could clear that up for me.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > C# Newbie


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap