gpt4 book ai didi

asp.net - 如何将编辑器中的html代码插入MySQL数据库?

转载 作者:行者123 更新时间:2023-11-29 09:10:31 26 4
gpt4 key购买 nike

我有一个 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com