jeudi 29 septembre 2016

how can i add multiple value from listcheckedbox?

how can i add multiple value from listcheckedbox ? i have search in engine many of them store it with count first and the checked value. is there a way just get the selected value ? error

the code i use.

  public void savenote()
    {
        DataTable dtsvnote = new DataTable();
        DataSet dssvnote = new DataSet();
        SqlCommand command = new SqlCommand();
        SqlDataAdapter adapter = new SqlDataAdapter();
        SqlParameter para1 = new SqlParameter();
        try
        {
            dtsvnote.Clear();
            dssvnote.Clear();
            command.Connection = myConnection;
            command.CommandText = "UPDATE member " +
                "set note ='" + checkedListBoxControl1.SelectedItems.ToString()+"," + "' WHERE userid= '" + 734 + "';";                                     

            myConnection.Open();
            adapter.UpdateCommand = command;
            command.ExecuteNonQuery();
        }
        catch (Exception ex)
        {
            MessageBox.Show("error" + ex);
        }
        myConnection.Close();
    }

the display of form

note

so it the output become greatenergy;listenwell

if its duplicate please send the link.




Aucun commentaire:

Enregistrer un commentaire