I am trying to insert the record by the Excel registration to SQL, I have already loaded my excel, I go through it with a foreach in the following way:
SqlConnection cnn = new SqlConnection();
cnn.ConnectionString = "Data Source=Localhost;Initial Catalog=DevLiverpool_DB; Integrated Security = True";
cnn.Open();
foreach (DataRow row in dt.Rows)
{
SqlCommand cmnd = new SqlCommand("insert into Ciudad_tb (Id_ciudaddestino, Ciudadestino) values (" + row.ItemArray[0].ToString() + ",'" + row.ItemArray[1].ToString() + "'", cnn);
cmnd.ExecuteNonQuery();
}
But it sends me an error near my syntax, I already debugged it and I'm observing that just as I do the item array brings all the data and not just the one I want to insert, I do not know if it explains it well ... Greetings and thanks for the help