Im trying to loop over some array, and through that , update with new parameters..
this is my code :
for (int i = 0; i < wholeArr.Length - 1; i++)
{
string[] temp = wholeArr[i].Split('-');
UpdateQuery(int.Parse(temp[1]), int.Parse(temp[0]));
}
and this is my update function :
public void UpdateQuery(int id, int newOrder)
{
string sql = "update Tama38News set [OrderingNumber] = @OrderingNumber where [ID] = @ID";
con = new SqlConnection(connection);
con.Open();
adapter = new SqlDataAdapter();
command = new SqlCommand(sql, con);
command.Parameters.AddWithValue("@ID", id);
command.Parameters.AddWithValue("@OrderingNumber", newOrder);
command.ExecuteNonQuery();
con.Close();
}
the thing is, Im not getting any exception, but for some reason the DB doesnt get affected..
any idea why ?
Make sure that temp[1] is actually the ID you want and temp[0] is the newOrder id and that you are not mixing them up.