Hi I am inserting the following stirn in databse but its giving me error
the string is " L'Oreal assures us "You're worth it"." now because i have single ' after L and then " and then again single ' its giving me error at L'Oreal.Can anyone help me with this.
Thanks

Single quotes in a string should be fine, but you might need to escape the embedded double quotes.

string s = "L'Oreal assures us \"You're worth it\".";

right now i am using replace function something like this

string text1 = item.text.ToString();

                text1 = text1.Replace("’", "''");
                text1 = text1.Replace("'", "''");
                string sent2 = sent;
                sent2 = sent2.Replace("'", "''");
                sent2 = sent2.Replace("’", "''");

how escape embedded double quotes

Can you tell me how can i do this by creating another method and then call that method in another method. i have a method savedatabse like this:-

private void saveDataInDatabase()
        {
        

            processtext();
            string[] key = null;
           
                
               
                
                        
                        //insert query procedure here
                        string myString;
                        SqlConnection cn = new SqlConnection(@"Server=208.124.179.198;Database=Content_text;UID=sa;Password=November17th;");
                        cn.Open();
                        myString = @"INSERT INTO contentTbl(Author,Title,text,badsent,all_sent,sentences,key_word,noun,verbs,adjectives)  Values('" + "me" + "','" + item.article + "','" + text1 + "','" + item.badSent + "','" + item.allSentNumber + "','" + sent2.ToString() + "','" + keywords.ToString() + "','" + noun.ToString() + "','" + verbs.ToString() + "','" + adj.ToString() + "')";
                        SqlCommand myCmd = new SqlCommand(myString, cn);
                        myCmd.ExecuteNonQuery();

                        cn.Close();

                
            
                

            }

i want to create anothe method in which i ll process all the text which is processtext.so far it looks like this

private void processtext(string nouns, string verb, string adjectives, string sentence, string key)
        {
            
           for (int i = 0; i < allData.Count; i++)
            {
                string sent = "";
                string adj = "";
                string noun = "";
                string verbs = "";
                string keywords = "";
                TextProcItem item = (TextProcItem)allData[i];
                string text1 = item.text.ToString();

                text1 = text1.Replace("’", "'");
                text1 = text1.Replace("'", "''");
                string sent2 = sent;
                sent2 = sent2.Replace("’", "'");
                sent2 = sent2.Replace("'", "''");
                
                
                foreach (string value in item.nouns)
                {
                     noun += (value + ",");
                }
                foreach (string value in item.verbs)
                {
                     verbs += (value + ",");
                }
                foreach (string value in item.adjectives)
                {
                    adj += (value + ",");
                }
                foreach (string value in item.keywords)
                {
                    keywords += (value + ",");
                }
                foreach (string value in item.sentences)
                {
                    sent += (value + ",");
                }
           }
         }

i want to call this method in my savetodatabse method.
thanks for all the help

This article has been dead for over six months. Start a new discussion instead.