Click here to Skip to main content
15,898,981 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
please help , i cannot find the mistake from below code, but it tell me the update statement is wrong
VB
Private Sub update_prosedure()
        connection = New OleDbConnection(connetionString)
        Dim cmd As New OleDb.OleDbCommand

        cmd.Connection = connection

        Dim a As String = "UPDATE material Set ([NOREG]=@NOREG], [DATE]=[@DATE], [SUPPLIER]=[@SUPPLIER], [NOSJL]=[@NOSJL], [PO]=[@PO], [STYLE]=[@STYLE], [DESCRIPTION]=[@descrip], [COLOR]=[@COLOR], [SIZE]=[@SIZE], [QTY]=[@QTY], [UOM]=[@UOM], [NOCSTMBN]=[@NOCSTMBN]) WHERE [NOREG]=[@NOREG]"
        With cmd.Parameters
            .AddWithValue("@NOREG", txt_noreg.Text)
            .AddWithValue("@DATE", txt_date.Text)
            .AddWithValue("@SUPPLIER", txt_supplier.Text)
            .AddWithValue("@NOSJL", txt_nosjl.Text)
            .AddWithValue("@PO", txt_po.Text)
            .AddWithValue("@STYLE", txt_style.Text)
            .AddWithValue("@descrip", txt_descrip.Text)
            .AddWithValue("@COLOR", txt_color.Text)
            .AddWithValue("@SIZE", txt_size.Text)
            .AddWithValue("@QTY", txt_qty.Text)
            .AddWithValue("@UOM", cmb_uom.Text)
            .AddWithValue("@NOCSTMBN", txt_nocstmbn.Text)
        End With
        connection.Open()
        cmd.CommandText = a
        '  cmd = New OleDbCommand(a, connection)
        cmd.ExecuteNonQuery()

        ref_table()
        connection.Close()
        clear()

    End Sub
Posted
Updated 28-Sep-12 6:48am
v2

1 solution

Don't use round bracket around after the SET part, and you don't need square bracket around the parameters in the statement either:

SQL
UPDATE material Set [NOREG]=@NOREG, [DATE]=@DATE, [SUPPLIER]=@SUPPLIER, [NOSJL]=@NOSJL, [PO]=@PO, [STYLE]=@STYLE, [DESCRIPTION]=@descrip, [COLOR]=@COLOR, [SIZE]=@SIZE, [QTY]=@QTY, [UOM]=@UOM, [NOCSTMBN]=@NOCSTMBN WHERE [NOREG]=@NOREG
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900