I have this, and made a scope identity on another insert that makes the int id variable
foreach (ListItem item in CheckBoxList1.Items)
{
if (item.Selected)
{
int CheckId = Convert.ToInt32(item.Value);
cmd.CommandText = "INSERT INTO FarveTilCykel (fk_cy_id, fk_farve_id) VALUES (@cy, @farve)";
cmd.Parameters.Add("@cy", SqlDbType.VarChar).Value = id;
cmd.Parameters.Add("@farve", SqlDbType.VarChar).Value = CheckId;
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
} //end if
} //end foreach
The problem is (I think) that, when it has run it 1 time and does second, the @cy is already declared, how can I make it different for each time?
mysql,postgresql,sql-server,oracleordb2- or something else entirely.