这是我的代码,我只能保存第一项。我需要将整个列表保存在一个数据库列中。感谢您的帮助。
Dim mysql As String = "UPDATE tbl_item SET my_item = (@myitems) WHERE id = '" & Label6.Text & "'"
Dim mycmd As New MySqlCommand(mysql, sConnection)
Dim values As New List(Of String)
values.Add(ListBox1.Items.Add(values))
Dim sqlParam As New MySqlParameter With {.ParameterName = "@myitems", .DbType = DbType.String}
mycmd.Parameters.Add(sqlParam)
Dim i As Integer
For i = 0 To values.Count - 1
sqlParam.Value = (ListBox1.Items(i) & ";")
mycmd.ExecuteNonQuery()
Next
答案 0 :(得分:0)
Dim i As Integer
For i = 0 To values.Count - 1
If sqlparam.value = "" Then
sqlparam.value = listbox1.Items(i) & ";"
Else
sqlparam.value = sqlparam.value & listbox.Items(i) & ";"
End If
Next
mycmd.ExecuteNonQuery()
如果此代码失败,请尝试将mycmd.execute ....放在..
中