Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 965305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:58:31+00:00 2026-05-16T01:58:31+00:00

This is probably a simple one… Right now I have a working web service

  • 0

This is probably a simple one…

Right now I have a working web service (programmed in c#) and it offers up two webmethods that either read or write data to a MS SQL database. What I want to know is this… Do I have to worry about errors when multiple users try to connect to, reading from, and writing to the database? Furthermore, should I be using threads and locks in my webmethods when they access the database (right now, I’m not using threads or locks)?

Here is some idea of what I have running now (code snippet):

[WebMethod(Description = "Attempts to post a new score to the scoreboard.")]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public TextMessage UpdateScoreboard(string password, string playerName, 
          int level, int gameBoard, string auth)
    {
        SqlDataReader myReader = null;
        SqlCommand myCommand = null;
        SqlConnection myConnection = null;

        /*
        The method then attempts to connect to the DB, 
        look for a duplicate playerName, and if there isn't one,
        data is entered into the DB ... using the INSERT command.
        */
    }

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T01:58:32+00:00Added an answer on May 16, 2026 at 1:58 am

    You don’t have to worry about it heavily depending on the situation. As is the nature of databases, you might have situations were folks reading from the database are getting ‘old’ information, as in they might not get information that was entered recently from when the read operation took place. If this is a big issue for your specific situation then you’ll have to think about using locks, however if that isn’t a big deal you should be fine.

    However, if you start getting a heavy volume of requests either to write or read, you may have to worry about locking or concurrency issues. Based on the simplicity it doesn’t really sound like you have to worry much about it though.

    Regardless, make sure you handle exceptions and plan for the obvious things that could happen (connection to SQL is down, various error conditions that may be present in your code, etc.)

    I generally recommend against locking and threading unless you absolutely have a good reason to go down those paths. Threading should also be far less of an issue here due to the nature of web services, they are designed to handle concurrent usage. That is unless you have a very long running service request, then I’d move that into a thread, but, the less complexity the better.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.