|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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/ |
|
#3
|
|||
|
|||
|
Thanks for that, glad you could clear that up for me.
![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > C# Newbie |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|