I need to declare parameter once and then use it several times with Insert query like:
SqlCommand mainCMD = new SqlCommand("", conn);
for (int i = 0; i < 5; i++)
{
mainCMD.CommandText += "INSERT INTO Country (name) VALUES (@cntr)";
mainCMD.Parameters.AddWithValue("@cntr", "Country" + i);
}
mainCMD.ExecuteNonQuery();
How can i do it?
mainCMD.CommandText5 times to itself.