开发者

problem in update query!

I had written a query like this

  string strUpdateQuery = "UPDATE M_QA SET ANSWER = '" + txtEditorAnswer.Text.Trim().Replace("'", "''")
                                  开发者_运维问答    + "', UPDATED_ON = getDate(), UPDATED_BY = '" + this.Session["UserId"].ToString()
                                      + "' WHERE PK_ID = " + _currentQuestionId + " AND IS_ACTIVE = 1";

but the value doesn't get updated untill i put a breakpoint at this query.

Can anyone please help me..


  1. You should be using a library to assemble your SQL statements rather than direct concatenation.
  2. What does SQL Profiler show as the query being passed to the server?
  3. If I had to wager a guess, I would say that either the question with the given primary key does not exist at the time the query is executed or the question is not yet active at the time the query is executed. Either way, you need to verify the exact query that is actually being passed to the server (via SQL Trace/Profiler) and you need to verify that the primary key value actually exists at the time the query is executed and that the question is actually marked as active.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜