Click here to Skip to main content
16,021,125 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all
for the last 5 hrs i am trying to sort out this error , could anyone please tell me what is the wrong with the below code.

thanks

Try
            Dim conn As New OleDbConnection(connstrg)
            Dim sqlstr As String = " select * from admin_skills"
            Dim dt As New DataSet
            Dim n As String = Label1.Text
            Dim dd As Date
            Dim go String
            dd = DateTimePicker6.Value.Date
            If CheckBox16.Checked = True Then
                go = "no"
                  else 
                   go = "yes"
            End If
            
            Dim cmd As New OleDbCommand
            cmd.Connection = conn
            cmd.CommandType = CommandType.Text
            conn.Open()
            cmd = New OleDbCommand("UPDATE admin_skills SET goods=?,g_date=?,g_accp=? where op_id=?", conn)
            cmd.Parameters.AddWithValue("goods", go)
            cmd.Parameters.AddWithValue("g_date", dd)
            cmd.Parameters.AddWithValue("g_accp", go)
            
            cmd.ExecuteNonQuery()
            conn.Close()
            MsgBox(" Record Updated  ", MsgBoxStyle.Information)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
Posted
Comments
thatraja 16-Dec-10 7:03am    
what's the error message? include that in your question.
edriso 16-Dec-10 11:09am    
the error message is in the title! thankx for your help (it is solved but if don't mind have a look to the below code)
thanks

1 solution

You must supply a value for the parameter op_id, which is in the where clause.

I hope this helps.

----------------------------------------------------------------
Signature: Apartamentos a venda em Guarulhos
 
Share this answer
 
Comments
Toniyo Jackson 16-Dec-10 7:08am    
Good solution
Manfred Rudolf Bihy 16-Dec-10 7:34am    
Good call!
edriso 16-Dec-10 8:08am    
YESS, thank you very much , because a copy the code from another form i forgot this line, anyway it work fine now
can ask for your help with another one please.
the following code i have syntax error but i can't figure it out
<pre>
conn.Open()
cmd = New OleDbCommand("UPDATE core_skill SET crimping=?,cr_trainer=?,cr_doc=?,cr_date=?,soldering=?,so_trainer=?,so_doc=?,so_date=?,brazing=?,br_trainer=?,br_doc=?,br_date=?, where op_id=?", conn)
cmd.Parameters.AddWithValue("crimping", cr)
cmd.Parameters.AddWithValue("cr_trainer", TextBox6.Text.ToString)
cmd.Parameters.AddWithValue("cr_doc", TextBox3.Text)
cmd.Parameters.AddWithValue("cr_date", dd)
cmd.Parameters.AddWithValue("soldering", so)
cmd.Parameters.AddWithValue("so_trainer", TextBox7.Text.ToString)
cmd.Parameters.AddWithValue("so_doc", TextBox4.Text)
cmd.Parameters.AddWithValue("so_date", dd1)
cmd.Parameters.AddWithValue("brazing", br)
cmd.Parameters.AddWithValue("br_trainer", TextBox8.Text.ToString)
cmd.Parameters.AddWithValue("br_doc", TextBox5.Text)
cmd.Parameters.AddWithValue("br_date", dd2)
cmd.Parameters.AddWithValue("op_id", Integer.Parse(Label1.Text))
cmd.ExecuteNonQuery()
conn.Close()
</pre>
silvioyf 16-Dec-10 21:59pm    
Try removing the comma before the where clause.
I can not see problems in parameters, since the variables (cr, dd, so, dd1, br and dd2) and controls (TextBox6, TextBox3, TextBox7, TextBox4, TextBox8, TextBox5 and Label1) are declared correctly.
edriso 17-Dec-10 5:29am    
again , another silly mistak, the problem was in the comma before the WHERE clause.
thank you very much

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