0

ok so in vb i have a combo box that i populated with selections for the user to choose from. i want what ever the user selects to upload to the db. I have other things in my form uploading to my db but i cant get what the user selected to upload?? how would i do this. here is my code for the other upload stuff that i did.

        Try
        Dim cmd2 As New MySqlCommand
        Dim insertStatment As String = "INSERT INTO comment (name,comment) VALUES 
        (@name,@comment)"
        cmd2 = New MySqlCommand(insertStatment, db_con)
        cmd2.Parameters.AddWithValue("@name", txtname.Text)
        cmd2.Parameters.AddWithValue("@comment", richtxtcomment.Text)

        cmd2.ExecuteNonQuery()
        MessageBox.Show("Thank your for your comment")

    Catch ex As Exception
        MessageBox.Show("bad")
4

1 回答 1

0

通常,对于 ComboBox,您需要执行以下操作:

cmd2.Parameters.AddWithValue("@whatever", combobox.SelectedValue);
于 2013-05-02T04:00:28.680 回答