Hi vbforums users!
I have the following code for Insert the checked items into mySQL:
And works great, but my problem is to UPDATE the same checkedlistbox.. MySQL put all the value's in FALSE.. This is my code:Code:For i = 0 To CheckedListBox1.Items.Count - 1 con = New MySqlConnection(cs) Dim cd As String = "INSERT INTO id_checklist(value,project,question) VALUES (@value,@project,@question)" cmd = New MySqlCommand(cd) cmd.Connection = con cmd.Parameters.AddWithValue("value", CheckedListBox1.GetItemChecked(i).ToString) cmd.Parameters.AddWithValue("project", txtproject.Text) cmd.Parameters.AddWithValue("question", CheckedListBox1.Items(i).ToString) con.Open() cmd.ExecuteNonQuery() con.Close() Next
any help?Code:For i = 0 To CheckedListBox1.Items.Count - 1 con = New MySqlConnection(cs) con.Open() 'Dim cb1 As String = "UPDATE id_checklist SET value = value - '" & CheckedListBox2.GetItemChecked(i).ToString & "' WHERE project= '" & ListView1.Items(i).SubItems(1).Text & "'" Dim cb1 As String = "UPDATE id_checklist SET value ='" & CheckedListBox1.GetItemChecked(i).ToString & "' WHERE project= '" & txtproject.Text & "'" cmd = New MySqlCommand(cb1) cmd.Connection = con cmd.ExecuteReader() con.Close() Next MsgBox("Complete..")
Best Regards!!




Reply With Quote
