fckeditor的数据库中插入

ligongruangao 2009-09-20 08:03:15
我写了一个脚本插入到Access数据库的fckeditor的值。我碰到下面的语法错误:
我插入一般网页源码都没问题,偶然间插入一个表时出现以下错误
//错误



语法错误 (操作符丢失) 在查询表达式 ''<table cellspacing="2" cellpadding="0" border="0" align="center" width="90%" id="table1">
<tbody>
<tr>
<td height="50" align="right" width="56"><img src="http://www.flblx.com/pic/ico_q.gif" alt="" /></td>
<td width' 中。




// 我的代码
protected void btn_about_Click(object sender, EventArgs e)
{

OleDbConnection cn = Class1.DBconnection();
string content = FCKeditor1.Value.ToString();
cn.Open();
OleDbCommand cmd = new OleDbCommand("update News set newsContent= '" + content + "' where ID="+id, cn);
cmd.ExecuteNonQuery();
Response.Write("<script language='javascript'>alert('保存成功!');</script>");



}










...全文
77 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
mngzilin 2009-09-20
  • 打赏
  • 举报
回复
插入的时候编码string content = Server.Encoding(FCKeditor1.Value.ToString());
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 gdjlc 的回复:]
string content = FCKeditor1.Value.ToString();
改为
string content = FCKeditor1.Value.Replace("'", "''");
[/Quote]
在插入的时候将单引号替换为双引号
逍遥游007 2009-09-20
  • 打赏
  • 举报
回复
有可能是sql语句的问题 看看是不是英文字符newsContent= '" + content + "' 把单引号改为英文的。
OutIT人 2009-09-20
  • 打赏
  • 举报
回复
"update News set newsContent= '" 多了一个符号
gdjlc 2009-09-20
  • 打赏
  • 举报
回复
string content = FCKeditor1.Value.ToString();
改为
string content = FCKeditor1.Value.Replace("'", "''");
sy_binbin 2009-09-20
  • 打赏
  • 举报
回复
<td width'

检查下你要插入的数据,可能存在单引号。
wiki14 2009-09-20
  • 打赏
  • 举报
回复
一般是插入的时候多了一个‘

检查你的sql语句
ligongruangao 2009-09-20
  • 打赏
  • 举报
回复
大家的方法我都试了,不行,我的代码的fckeditor控件有时可上传有时不能, 应该不是多了或少了引号问题
有我找到答案了
http://forums.asp.net/t/1357015.aspx
国外人也曾遇到这个问题

62,243

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧