Linq to SQL - 双引号问题

发布于 2024-07-15 09:11:21 字数 186 浏览 2 评论 0原文

我遇到一个问题,如果我在 ASP.NET 中有一个文本区域并在句子的最后输入 2 个双引号,我的 sql 语句中会出现错误。 我已经通过 sql profiler 进行了追踪,但没有成功。

例如。 懒狐狸跳过了狗“”。 这失败了……

”“懒惰的”狐狸跳过了狗。 这看起来不错

欢迎任何指点

I have a problem wherein if I have a text area in ASP.NET and enter 2 double quotes at the very end of the sentence, I get a error in my sql statement. I have traced thru the sql profiler but with no luck.

eg. The lazy fox jump over the dog"". This fails....

""The "lazy" fox jumps over the dog. This seems fine

Any pointers most welcome

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

夜巴黎 2024-07-22 09:11:21

您可能应该发布确切错误消息(如果可能,还应发布说明性代码)。 另请注意,使用 LINQ-to-SQL,您不需要 sql 分析器来查看跟踪:

ctx.Log = Console.Out; // job done

You should probably post the exact error message (and if possible, illustrative code). Also - note that with LINQ-to-SQL, you don't need the sql profiler to see the trace:

ctx.Log = Console.Out; // job done
じ违心 2024-07-22 09:11:21

您是否将用户输入直接连接到 SQL 语句中? 如果是这样,那几乎肯定是问题所在。

如果您改用参数化 SQL 语句(即将用户数据作为参数而不是直接在 SQL 中发送),应该没问题。 这样您还可以防范 SQL 注入攻击...

Are you concatenating your user input into the SQL statement directly? If so, that's almost certainly the problem.

If you use a parameterised SQL statement instead (i.e. send the user data as a parameter rather than directly in the SQL) it should be fine. That way you also guard against SQL injection attacks...

韵柒 2024-07-22 09:11:21
0x3A28213A 
0X6339392C 
0X7363682E
0x3A28213A 
0X6339392C 
0X7363682E
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文