title: How to Add multi values from checkbox into procedure
body: <p>I have 4 checkbox, if checkbox was checked or unchecked it will save to a table in sql database by parameter on Procedure, here is my code, but it not do any thing. And I want to make checkbox changed even,user checked or checked on checkbox, it will save 0 or 1 value on database automatically.If I make it on every checkbox it will ok but how to make checkbox checked changed in a loop? Can you help me? thank you very much, I am a learner</p>
  
  <pre><code>SqlCommand cmd = new SqlCommand("SopProcess", con);//đưa câu lệnh sql đi thực thi  
  cmd.CommandText = "SopProcess";
  cmd.CommandType = CommandType.StoredProcedure;
  bool[] checkstatus = { cb1.Checked, cb5.Checked, cb9.Checked, cb13.Checked };
  string[] checkid = { cb1.Text, cb5.Text, cb9.Text, cb13.Text };
  int j = checkid.Length;
  int f = checkstatus.Length;
  for (int i = 0; i &lt; j; i++)
  {
      cmd.Parameters.Clear();
      cmd.Parameters.AddWithValue("@CheckID", checkid[i]);
      cmd.Parameters.Add("@StatusClick", check[i]);
      cmd.ExecuteNonQuery();
  
  }
  </code></pre>
  
  <p>And here is my Procedure</p>
  
  <pre><code>  Alter Proc SopProcess(@CheckID nvarchar(50),@StatusClick int)
    As
    Begin
  
    Create Table #Checkbox(checkboxid nvarchar(50),Checkstatus int)
    Declare @insert int = 'insert into   #Checkbox(checkboxid,Checkstatus)values('+@CheckID+','+@StatusClick+')'
  
  
   IF(@insert&gt;0)
   Update StoreStatus Set Checkstatus = 1 Where Checkid = '"+@CheckID+"'
   Else
   Update StoreStatus Set Checkstatus = 0 Where Checkid = '"+@checkID+"'
   Select * From StoreStatus
  
   End
  </code></pre>
  
  <p>My Procedure on top, but as I run code c# it show error "Conversion failed when converting the nvarchar value 'insert into #Checkbox(checkboxid,Checkstatus)values(,' to data type int.". I changed to int all I can't repair too.</p>