且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SQL插入查询执行两次

更新时间:2023-02-05 19:12:49

我什么都看不到你的code,将执行了两次。我认为它是被调用两次。把一个破发点,在 addNewComment ,如果它被称为两次看堆栈跟踪,看看它是从两个场合呼吁。

I can't see anything in your code that would execute it twice. I'd assume that it is being called twice. Put a break point at addNewComment and if it is being called twice look at the stack traces to see where it is being called from on both occasions.

也许你有一个事件被调用两次为例。这可以在ASP.NET发生,如果你俩都启用了事件的自动布线,并已连接事件了明确。

Maybe you have an event being called twice for example. This can happen in ASP.NET if you both have auto wiring of events enabled and have wired the event up explicitly.

顺便说一句,你绝对应该使用参数化查询的不是字符串连接。我假设注释用户提供的输入?在这种情况下,你是在和自己的SQL注入攻击和你已经表明了code。

By the way you should definitely use parametrized queries not string concatenation. I'm assuming that comment is user supplied input? In which case you are setting yourself up for a SQL injection attack with the code you have shown.