Click here to Skip to main content
16,000,960 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have written this Update statment in c# dot net
C#
string va=d1.SelectedItem.Value;
//ta1.Value=va;

com=con.CreateCommand();
com.CommandText="UPDATE notification SET notice = '" + ta1.Value + "' where id='" + va + "'";


bt error are given
Syntax error (missing operator) in query expression ''This is Kamna Charitable Trust for the country INDIA working in all over India and also nebhour's country.' where id='3''.
Posted
Updated 14-Oct-11 21:49pm
v2

1 solution

Your string has the ' character in it which sql server takes as a string begin and end deliminator. You will have to use '' (double in your string).

Use the following line instead :
C#
com.CommandText="UPDATE notification SET notice = '" + ta1.Value.Replace("\'","\'\'") + "' where id='" + va + "'";
 
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