.net - MS SQL -- Okay for multiple users to connect/read/write to database from a web service (c#)? -


This is probably a simple ...

I have a working web service (programmed ) In C # and it provides two webmissions that either read or write data in MS SQL database. What I want to know is this ... Do I need to worry about errors when many users from the database Try to connect, read, and write? Also, when should I use threads and locks in my webmethods while using the database (right now, I'm not using threads or locks)?

Here are some ideas that I'm going to (code snippet):

  [WebMethod (Description = "Attempting to post a new score on the scoreboard.") ] [ScriptMethod (Response format = Response format. Jason)] PublicTextSupgrade updateScoreboard (string password, string playername, integer level, int gameboard, string audio) {SqlDataReader myReader = null; SqlCommand myCommand = Null; SqlConnection myConnection = null; / * Method then attempts to connect to DB, search for a duplicate player name, and if none, the data is entered in DB ... using the INSERT command. * /}  

Thanks.

You do not have to depend on the situation to worry about it. As the nature of the database, due to the circumstances, people reading from the database are getting 'old' information, because they can not obtain the information that was received recently by the action taken after reading. If this is a big issue for your particular situation, then you have to think about using the lock, however, if this is not a big deal then you should be fine.

However, if you have to type or read the amount of bulk requests, you may worry about locking or concurrency issues, on the basis of simplicity, this is not really true as you can There is more to worry about.

However, make sure that you handle exceptions and plan for clear things (which are below the connection to SQL, different error conditions that may exist in your code etc.).

I generally recommend locking and threading, as long as those paths do not have a good reason to go down. Threading due to the nature of web services here should be very few of the issues, they are designed to handle concurrent usage. Unless you have a long-running service request, then I take it in a thread, but less complexity is better.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -