title: How to add value from checkedlistbox into database using stored procedure c# windows forms?
body: <p>I'm trying  to add checked values from checkedlistbox using stored procedure and C# </p>
  
  <pre><code> public static void CreateDrugsListBox(CheckedListBox DrugsList) 
     {
         try
         {
             SqlConnection con = new SqlConnection(@"connection");
             SqlCommand cmd = new SqlCommand("InsertData_DrugsListBox", con);
             cmd.CommandType = CommandType.StoredProcedure;
  
             con.Open();
             foreach (string  itemchecked in DrugsList.CheckedItems) 
             {
                 cmd.Parameters.Clear();           
                 cmd.Parameters.AddWithValue("@DrugsValue", itemchecked); 
                 cmd.ExecuteNonQuery();
  
             }
             con.Close();
        }
  
         catch (Exception ex)
         {
  
             MessageBox.Show("Error"+ex, "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
  
         }
  
     }
  </code></pre>
  
  <p>it displays an error like: </p>
  
  <pre><code>errorSystem.invalidcastException: imposible to make a cast of an object type System.Data.DataRowView in type System.String
  </code></pre>