Jayakumar

Jayakumar

  • NA
  • 205
  • 21.1k

Multithreading in WebService

Jun 20 2014 1:35 AM
i made a webservice with a webmethod that handles big chunks of data, to be written in a ms sql server database table. (about 7000 rows per session)
the webservice is called at random times by different clients, which send the data.

the webservice has only 1 database connection with the database.
the webmethod is a loop that reads the chunks data and inserts it into the db-table.

here's the problem:
when two clients call the webmethod at the same time, one call succeeds and one call fails. i think this is because the database is locked during the the loop that executes the insert methods (SqlCommand.ExecuteNonQuery())

has anyone had the same problem or a solution for this problem?