Forums

This topic is locked

Syntax error in UPDATE statement

Posted 27 Jul 2006 11:38:48
1
has voted
27 Jul 2006 11:38:48 lucky ger posted:
The following code generates an error and I am not sure why. The error shows syntax error in UPDATE statement which points to "UpdateCommand.ExecuteNonQuery()". Anyone have any ideas?



Dim CONNECTION_STRING As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\87- 08 \shareddocs\User.mdb"
Dim access As New OleDbConnection
access = New OleDbConnection(CONNECTION_STRING)

Dim UpdateCommand As OleDbCommand = New OleDbCommand()
UpdateCommand.Connection = access

UpdateCommand.CommandText = "Update Admin Set [AcadYr] = @Ay, [ComName] = @Cn,[Sal1] = @Sa1, [Sal2] = @Sa2, [Firstname1] = @Fn1, [Firstname2] = @Fn2, [Lastname1] = @Ln1, [Lastname2] = @Ln2, [Status1] = @s1, [Status2] = @s2, [Designation1] = @Dg1, [Designation2] = @Dg2, [Add1] = @Add1, [Pcode] = @Pc, [Otel] = @Ot, [Dline1] = @D1, [Dline2] = @D2, [Faxno] = @Fn, [Email1] = @Em1, [Email2] = @Em2, [Supervisor1] = @Sp1, [Supervisor2] = @Sp2, [ProjId] = @Pi, [ProjTitle] = @Pt, [ProjCatDes] = @Pcd, [ProjCatCode] = @Pcc, [TechAreaDes] = @Tad, [Remarks] = @Rem, [Awards] =@Aw, [PDonation] =@PDon, [Year] =@Year, [TPrizes] =@Tz, [Time] =@Tim WHERE Id = @Id"

UpdateCommand.Parameters.AddWithValue("@Ay", AcadYrComboBox.Text)
UpdateCommand.Parameters.AddWithValue("@Cn", TextBox32.Text)
UpdateCommand.Parameters.AddWithValue("@Sa1", ComboBox26.Text)
UpdateCommand.Parameters.AddWithValue("@Sa2", ComboBox25.Text)
UpdateCommand.Parameters.AddWithValue("@Fn1", TextBox27.Text)
UpdateCommand.Parameters.AddWithValue("@Fn2", TextBox22.Text)
UpdateCommand.Parameters.AddWithValue("@Ln1", TextBox29.Text)
UpdateCommand.Parameters.AddWithValue("@Ln2", TextBox24.Text)
UpdateCommand.Parameters.AddWithValue("@S1", ComboBox31.Text)
UpdateCommand.Parameters.AddWithValue("@S2", ComboBox32.Text)
UpdateCommand.Parameters.AddWithValue("@Dg1", TextBox28.Text)
UpdateCommand.Parameters.AddWithValue("@Dg2", TextBox23.Text)
UpdateCommand.Parameters.AddWithValue("@Add1", TextBox33.Text)
UpdateCommand.Parameters.AddWithValue("@Pc", TextBox34.Text)
UpdateCommand.Parameters.AddWithValue("@Ot", TextBox35.Text)
UpdateCommand.Parameters.AddWithValue("@D1", TextBox30.Text)
UpdateCommand.Parameters.AddWithValue("@D2", TextBox25.Text)
UpdateCommand.Parameters.AddWithValue("@Fn", TextBox36.Text)
UpdateCommand.Parameters.AddWithValue("@Em1", TextBox31.Text)
UpdateCommand.Parameters.AddWithValue("@Em2", TextBox26.Text)
UpdateCommand.Parameters.AddWithValue("@Sp1", ComboBox23.Text)
UpdateCommand.Parameters.AddWithValue("@Sp2", ComboBox22.Text)
UpdateCommand.Parameters.AddWithValue("@Pi", ComboBox21.Text)
UpdateCommand.Parameters.AddWithValue("@Pt", TextBox1.Text)
UpdateCommand.Parameters.AddWithValue("@Pcd", ComboBox18.Text)
UpdateCommand.Parameters.AddWithValue("@Pcc", ComboBox19.Text)
UpdateCommand.Parameters.AddWithValue("@Tad", ComboBox20.Text)
UpdateCommand.Parameters.AddWithValue("@Rem", TextBox19.Text)
UpdateCommand.Parameters.AddWithValue("@Aw", ComboBox17.Text)
UpdateCommand.Parameters.AddWithValue("@Id", IdComboBox.Text)
UpdateCommand.Parameters.AddWithValue("@PDon", ComboBox30.Text)
UpdateCommand.Parameters.AddWithValue("@Year", ComboBox33.Text)
UpdateCommand.Parameters.AddWithValue("@Tz", ComboBox24.Text)
UpdateCommand.Parameters.AddWithValue("@Tim", Time.Text)

access.Open()
UpdateCommand.ExecuteNonQuery()
access.Close()

Reply to this topic