So I'm stumped on this problem.
I need to get all the column values of another table (tbladdbenefit) and add them to another table (payrolltable) and insert all the values of the first table into a single cell.
In this case, I'm trying to insert all of the values of column "benefit" to a single cell of "benefit" on the new table, the same thing for "BenefitAmount".
So far I am using Parameters.AddWithValue but to no avail. I have 2 data from the column benefit from the first table but it only shows the record I highlighted. Which is not what I want to do. I want to display and add all the records of my parent table
Any suggestions?
 cmd = new SqlCommand("INSERT INTO payrolltable " + 
                      "(Name, " + 
                      "Position, " + 
                      "Honoraria, " + 
                      "Total, " + 
                      "Benefit, " + 
                      "BenefitAmount, " + 
                      "Deduction, " + 
                      "DeductionAmount) " + 
                      "VALUES " + 
                      "(@name, " + 
                      "@position, " + 
                      "@honoraria, " + 
                      "@total, " + 
                      "@benefit, " + 
                      "@benefitamount, " + 
                      "@deduction, " + 
                      "@deductionamount)", con);
 cmd.Parameters.AddWithValue("@name", txtfname.Text + " " + txtlname.Text);
 cmd.Parameters.AddWithValue("@position" , txtposition.Text);
 cmd.Parameters.AddWithValue("@honoraria", txtsalary.Text);
 cmd.Parameters.AddWithValue("@total", 323232);
 cmd.Parameters.AddWithValue("@benefit", SqlDbType.VarChar);
 cmd.Parameters.AddWithValue("@benefitamount", SqlDbType.BigInt);
 cmd.Parameters.AddWithValue("@deduction", " ");
 cmd.Parameters.AddWithValue("@deductionamount", " ");
              
                
 for (int i = 0; i < tbladdbenefit.Rows.Count - 1; i++)
 {
  cmd.Parameters["@benefit"].Value = tbladdbenefit.Rows[i].Cells[1].Value;
  cmd.Parameters["@benefitamount"].Value = tbladdbenefit.Rows[i].Cells[2].Value;
 }
 
    