No, you do not need a lock, but you need to create a new SqlConnection for each insert. The documentation states that members of an SqlConnection instance are not thread safe.
Edit 2:. Otherwise, threads are unsafe if you cannot use one SqlConnection for multiple threads. But if each thread has its own SqlConnection , inserts are fine. The database itself is an ACID property, and therefore concurrent connections trying to insert data are safe and well defined.
Edit: But you have to be careful when deleting strange code if you cannot understand why it was written this way in the first place. This can easily have some kind of side effect, which is non-trivial if you look at the database code. But, on the other hand, if the code was written by someone who inserted some kind of random code found through Google, then it would be best to rewrite the code anyway.
source share