C# Update Table using SqlCommand.Parameters

≡放荡痞女 提交于 2019-12-05 11:20:32

UPDATE FROM is invalid syntax (edit: OP corrected this). The problem might also be the "text" column. text is a keyword in SQL Server, since it's a datatype. Try putting brackets around it.

UPDATE yak_tickets 
SET email = @emailParam, 
    subject = @subjectParam, 
    [text] = @textParam, 
    statusid = @statusIDParam, 
    ticketClass = @ticketClassParam 
WHERE id = @ticketIDParam

Had to use if(!Page.IsPostBack)

Couple of questions:

  1. Is this inside of a transaction thats getting rolledback?
  2. Have you verified that you @ticketIDParam matches a set of rows on the table? Especially if its not just a integer key
  3. Are you updating rows that have no side effects (i.e. your updating to the same values)?
  4. Can you provide the paramaters.Add statements for this query
  5. Is there a trigger or other setting on the table (I assume not, as you did not mention anything).
  6. You said you know the params are working correctly, can you say how you verified this? (profiler, visual inspection, etc).

Sounds like your hosting provider limits your debug options, forcing you to do it the old fashioned way. What if immediately after the update, you put something like:

;SELECT @@ROWCOUNT

then instead of ExecuteNonQuery, do ExecuteScalar, and see if SQL even thinks its updated anything.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!