C# String Adding Extra "\"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • donllll
    New Member
    • Dec 2007
    • 2

    #1

    C# String Adding Extra "\"

    Hello, I am coding an web service factory application.

    In service implementation code I am trying to pass a domain and user to a stored procedure on a SQL Server 2005 Database.

    The problem is I cannot get c# to NOT add the extra "\"

    cmd.CommandText = @"exec dbo.spWorldCloc kGetTimezones DS\john.doe";

    I tried even hardcoding to get the process to work - in the above example I am still seeing "...DS\\xxxx.xx x" when I click on the variable during code execution.

    I am able to take code and manually run it on the SQL Server.

    I also tried using SQLParameter and adding a parameter - but did not seem to work - I thought the "@" was supposed to force a literal view of the string.

    Any ideas would be appreciated!
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    So cmd.CommandText = "exec dbo.spWorldCloc kGetTimezones DS\\john.doe"; doesn't work?

    Comment

    • donllll
      New Member
      • Dec 2007
      • 2

      #3
      Originally posted by kenobewan
      So cmd.CommandText = "exec dbo.spWorldCloc kGetTimezones DS\\john.doe"; doesn't work?
      In that case it keeps the double "\\" instead of signaling to keep a single quote - I did try @"--------\--------------" but that still kept "\\" in the value stored in the variable.

      Comment

      • Shashi Sadasivan
        Recognized Expert Top Contributor
        • Aug 2007
        • 1435

        #4
        If you are checking the value of the variable while debugging it, then that is how it will be stored. (it needs to know the escape characters). Try printing it out on the console, or onto a message box.

        If it still persists, do get back

        Comment

        Working...