ASP.NET C# Code Behind - SQL Update Command

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ibuprofen800mg
    New Member
    • Apr 2007
    • 4

    #1

    ASP.NET C# Code Behind - SQL Update Command

    I've tried so many ways now, I couldn't even list them. For the life of me, I cannot seem to update my database, I either get "error in syntax on update command"

    Code:
    			strSQL="UPDATE [q1], [q2], [q3], [q4], [q5], [q6], [q7], [q8],"+
    				" [q9], [q10], [q11], [q12], [q13], [q14], [q15],"+
    				" [q16], [q17], [q18], [q19], [q20], [q21], [q23],"+
    				" [q24], [q26], [q28], [q34], [q35], [q38], [q39],"+
    				" [q40], [q42], [q43], [q44], [q45], [q46], [q47],"+
    				" [q48], [q51], [q52], [q53], [q54], [q57], [q58],"+
    				" [q61], [q62], [q63], [q66], [q67], [q70], [q71],"+
    				" [q72], [q73], [q74], [q75], [q84], [q85], [q86],"+
    				" [q87], [q88], [q89], [q90], [q91], [q98], [q99],"+
    				" [q100], [q101],"+" [q102], [q103], [q104], [TCAIMSSite],"+
    				" [DTG_Submit], [LoginID], [TestPhase]"+
    				"  FROM t_EOT_User WHERE RecNum="+RecNum.Text;
    Anyone?
  • dbrewerton
    New Member
    • Nov 2009
    • 115

    #2
    Well...

    At first glance, I can tell that you've declared all the fields you want. But I think the problem is with an update clause, the format has to be like this:

    update table
    set field1 = "value";

    Basically, your DB doesn't know what you want it to place into those fields.

    Comment

    • dbrewerton
      New Member
      • Nov 2009
      • 115

      #3
      Also, the update clause you are using looks like a select statement.

      Comment

      • Curtis Rutland
        Recognized Expert Specialist
        • Apr 2008
        • 3264

        #4
        Yes, that is incorrect syntax. A SQL UPDATE statement looks like this:
        Code:
        UPDATE table_name 
        SET field_name = 'some_value', field_name2 = 'some_other_value' 
        WHERE some_identifying_field = some_condition
        If you are using a SqlDataAdapter and DataSet, you can use the .Update() method on the adapter, assuming that you have provided proper INSERT, UPDATE, and DELETE statements to the adapter.

        Comment

        Working...