Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. sp_who2

sp_who2

Scheduled Pinned Locked Moved Database
databasecsharpsharepointhelpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Darkness84
    wrote on last edited by
    #1

    I have written a service (in C#) that reads and writes to an SQL database. At the begining of the service I execute sp_who2 to see if another computer connected to the same database is already running the service and if it is I stop the service. My problem is that the service is not showing up in the results of sp_who2. Do you have to initialise anything either in the database or my service for it to be displayed by sp_who2?

    K 1 Reply Last reply
    0
    • D Darkness84

      I have written a service (in C#) that reads and writes to an SQL database. At the begining of the service I execute sp_who2 to see if another computer connected to the same database is already running the service and if it is I stop the service. My problem is that the service is not showing up in the results of sp_who2. Do you have to initialise anything either in the database or my service for it to be displayed by sp_who2?

      K Offline
      K Offline
      kubben
      wrote on last edited by
      #2

      You would need to have an open connection to the database for it to show up. Normally you would not want a service to hold open a connection to the database just so you can tell it is running. Why not just create a sql table that the service can look at? Hope that helps. Ben

      D 1 Reply Last reply
      0
      • K kubben

        You would need to have an open connection to the database for it to show up. Normally you would not want a service to hold open a connection to the database just so you can tell it is running. Why not just create a sql table that the service can look at? Hope that helps. Ben

        D Offline
        D Offline
        Darkness84
        wrote on last edited by
        #3

        I thought of that but if one computer is running the service and crashes the service's state would still be set to running in the table and then no other computer would be able to run that service until the state was manually reset in the database.

        K 1 Reply Last reply
        0
        • D Darkness84

          I thought of that but if one computer is running the service and crashes the service's state would still be set to running in the table and then no other computer would be able to run that service until the state was manually reset in the database.

          K Offline
          K Offline
          kubben
          wrote on last edited by
          #4

          Well, if it is that bad, then perhaps you should have the service on a regular basis insert a new record, so you know it is running. That way if the last record that was inserted was more then whatever time interval you decide on, you can have some certainty that the service has failed. Not a great solution, but it might work for you. Ben

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups