作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 html 编辑器,我试图将它生成的 html 插入数据库,然后在 SQL 表所在的另一个页面中检索它。 我正在使用带有一个文本字段的 asp 3.5 表格。这是代码:
MySqlConnection con = new MySqlConnection(@"Connection String ");//I've tested the connection string and its working fine
MySqlCommand cmd = new MySqlCommand("INSERT INTO ins (tes) VALUES ('" + Editor1.Content + "')", con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
这是我得到的错误:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'font-size: 18pt; line-height: 115%; font-family: "arial","sans-serif";'>Whatever' at line 1
如何做到这一点?提前致谢。
最佳答案
我认为你应该使用参数化查询来代替,并且永远不要相信用户数据输入。请问tes
的类型是什么,你能澄清一下错误是什么吗?异常(exception)吗?
关于asp.net - 如何将编辑器中的html代码插入MySQL数据库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5714997/
我是一名优秀的程序员,十分优秀!