使用UPDATE语句 [英] using UPDATE statment

查看:127
本文介绍了使用UPDATE语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在c#点网中编写了此更新语句

I have written this Update statment in c# dot net

string va=d1.SelectedItem.Value;
//ta1.Value=va;

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



给出bt错误
查询表达式中的



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''.

推荐答案

您的字符串中包含''字符,sql server将其作为字符串的开始和结束指示符.您将不得不使用''''(在字符串中加倍).

请改用以下行:
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 :
com.CommandText="UPDATE notification SET notice = '" + ta1.Value.Replace("\'","\'\'") + "' where id='" + va + "'";


这篇关于使用UPDATE语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆