User409696431 posted
You are not considering the case where there is no "," in the strLocation. If there is not, LastIndexOf returns -1, and you can't String.Remove at index position -1.
Check for a trailing comma first, then remove it if it is there. You can use TrimEnd(',') to do this. (It will remove a trailing comma, and, in fact, if there are more than one trailing commas, it will remove all of them)
Try:
cmd.Parameters.AddWithValue("@Location", SqlDbType.VarChar).Value = strLocation.TrimEnd(",");