Click here to Skip to main content
15,939,775 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i need to store text like "something" in a sql server database , with c# and

it is storing normar text , but i need to store text between double quotes . double quotes also should store along with text
CHill60 10-May-13 4:23am    
Use the Improve question link to post the code that you are using to write to the database so we can see where the problem is

How are you inserting the text to SQL. If you are not already I would suggest using a parametrised query as this should overcome that issue.
Share this answer
CHill60 10-May-13 4:28am    
asp.net4.50 10-May-13 7:51am    
hi can u please suggest me how to insert text like "some", in db , when i entered this text in a text box , i am using c#
Pheonyx 10-May-13 7:58am    
Have you read any of the suggestions below? the code examples etc? There is enough information for you to be able to do what you are trying to achieve?
Why are you ignoring peoples questions, it was requested by "CHill60" that you post the code you have tried, yet you haven't.
asp.net4.50 12-May-13 8:05am    
Hi , I am extremly sorry , the data with double quotes is storing in database , but it is not displaying in text box
CHill60 10-May-13 8:18am    
As Pheonyx has said ... look below. I can't improve on Solution 4
Try wrapping the values inside single quotes.

Share this answer
It looks you should double them, see, for instance "How to insert string containing single or double quotes" at Stack Overflow[^].
Share this answer
Johnny J. 11-May-13 4:16am    
You're doing it again! ;-)
I normally add the text as a parameter. Example:

private void testToolStripMenuItem_Click(object sender, EventArgs e)
            string text = @"This text ""contains"" double quotes";


        private void InsertText(string textToInsert)
            string query = "INSERT INTO MyTextTable (StoredText) VALUES (@TextToInsert)";

            using (SqlConnection conn = new SqlConnection("your sql connection string"))

                using (SqlCommand com = new SqlCommand(query, conn))
                    com.Parameters.AddWithValue("@TextToInsert", textToInsert);
Share this answer
I used method Replace("\"",""") to display text with double quotes
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900