sql server2005 unnecessary characters appended when data retrieved in c#

Posted on 2007-07-25
Last Modified: 2010-03-19
i have following problem
I enter some data into column of sql server2005 .Then try fetching it using sqlreader in c# using a stored proc.When i try to execute the stored procedure i m getting proper data.
data i m enetring is <table><tr><td><img src="hello.jpg" /></td></tr></table>
and it comes fine when i try in sql server only but when i fetch it in my appliaciton using sqlreader and stored comes to me as
<table><tr><td><img src=\"hello.jpg\" /></td></tr></table>
So blackslash is getting appended by itself to the double quotes.I am fetching thsi field in string variable
still trying to replace it in code behind using string.replace but it sodesnt allow me to use string.replace("\"",""").
Giving me errors.
can any1 suggest a way that data shud be comming up normaly in c# file than appending these special characters into it.

Question by:Devsolutions
    LVL 9

    Expert Comment

    The string you're viewing is actually correct.  You're probably just looking at it in the debugger; the debugger will show the delimiters on quotation characters, but if you actually display the string to the user in some manner, these delimiters will not be visible.
    LVL 1

    Author Comment

    Oh ok,but i am trying to replace the string
    encodehtml is having value fetched from database
    if (EncodedHTML.Contains("##linkNewsletter##"))
                    EncodedHTML.Replace("##linkNewsletter##", "abc");
     but its not replacing and going in and then coming out w/o replacing it,dont understand why then,thought this maybe coz i m getting string like that.and probaly probelm is that only
    LVL 9

    Accepted Solution

    the Replace method creates a new instance of the string with the value removed.  You need to reassign it to your original variable.  Also, you don't need to check if it contains the string first.

    EncodedHTML = EncodedHTML.Replace("##linkNewsletter##", "abc");
    LVL 1

    Author Comment

    HI burntsky.Thanks a lot,yes its working now,
    can u please also have a look at another question of mine

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now