Results 1 to 5 of 5

Thread: [RESOLVED] Setting the priority of start-up application/service

  1. #1

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Resolved [RESOLVED] Setting the priority of start-up application/service

    I have an app which auto-starts and connects to sql server but the thing is I am not sure if the sql server is started first and from time to time my app encounters an error wherein it cannot connect to the sql server, I would assume it is because sql server hasn't fully started yet or that my application started first, is there something I could do so that my app will wait for sql server to start before connecting?

    TIA
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  2. #2

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Setting the priority of start-up application/service

    Okay, this is how I am checking if SQL Server instance is already started before I try connecting to it.
    Code:
    Public Function SQLServerIsStarted() As Boolean
        Dim Process As Object
    
        SQLServerIsStarted = False
        For Each Process In GetObject("winmgmts:").ExecQuery("Select * from Win32_Process WHERE Caption = 'sqlservr.exe'")
            SQLServerIsStarted = True
        Next
    End Function
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [RESOLVED] Setting the priority of start-up application/service

    You could also just check to see if the Microsoft SQL Server service is started using the System.ServiceProcess.ServiceController class couldnt you? (I dont like WMI )
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  4. #4

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: [RESOLVED] Setting the priority of start-up application/service

    Quote Originally Posted by chris128 View Post
    You could also just check to see if the Microsoft SQL Server service is started using the System.ServiceProcess.ServiceController class couldnt you? (I dont like WMI )
    Its for VB6. But thanks for the info.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  5. #5
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [RESOLVED] Setting the priority of start-up application/service

    Ahhh right, sorry :P
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width