0

这是我的代码,我只能保存第一项。我需要将整个列表保存在一个数据库列中。提前感谢您的帮助。

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
4

1 回答 1

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.... 放入..

于 2013-04-01T06:28:31.900 回答