foreachコントロールを使用して文字列の配列をループし、各値を使用してデータベースに情報を挿入しようとしています。using句内でforeach変数を使用できない理由を誰かが理解するのを手伝ってもらえますか?
string[] ship_ids = ShipsInScope.Split('|');
foreach (string ship_id in ship_ids)
{
using (SqlCommand InsertCommand = new SqlCommand("insert into PROJECT_SHIP (CR_Number, Ship_Id) VALUES (@CR_Number, @CCF_Number)", DBConn))
{
InsertCommand.Parameters.Add("@CR_Number", SqlDbType.NVarChar, 10).Value = CRNumber;
InsertCommand.Parameters.Add("@Ship_Id", SqlDbType.NVarChar, 10).Value = Ship_Id;
InsertCommand.ExecuteNonQuery();
InsertCommand.Dispose();
}
}