Results 1 to 7 of 7

Thread: Kill Process

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2009
    Location
    Bangalore India
    Posts
    201

    Arrow Kill Process

    Hi!
    i have written a software in vb6 with Sql server 2000 as database.
    the software works fine but i have few problems which i could solve.
    1) when i close the application i find that the process in the task manager is still running?
    how to kill the process once i exit from the software.

    please help me in this regard.
    its very urgent.

    with regards!
    Sethuraman R

  2. #2
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: Kill Process

    may be u didn't close the recordset, try something like this..
    Code:
        If Not Rs Is Nothing Then
            'first, check if the state is open, if yes then close it
            If (Rs.State And adStateOpen) = adStateOpen Then
                Rs.Close
            End If
            'set them to nothing
            Set Rs = Nothing
        End If
    then unload all forms
    Code:
    Dim F As Form
       For Each F In Forms
          Unload F
          Set F = Nothing 'clean up
       Next
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


  3. #3
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Kill Process

    With this little information, I cannot comment much... Can you show your project for a faster resolution?
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Kill Process

    Can you place a breakpoint on your code that checks if the rs is open and if so closes it? I dont believe you need to do a bitwise comparison on it. Just check if its adStateOpen and if so, close
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Kill Process

    You should use a bitwise comparison as seenu_1st showed, because the .State property of ADO objects can have multiple values at the same time - such as Open and Executing.


    For an explanation (and example code) for how you should be closing a form/program, see the article How should I close my form/program/class? from our Classic VB FAQs (in the FAQ forum)

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Kill Process

    Then I guess Microsoft is wrong...

    Note the "GetState" procedure as well as the error handler:
    http://msdn.microsoft.com/en-us/libr...60(VS.85).aspx

    Code Examples 1-5:
    http://msdn.microsoft.com/en-us/library/ms807027.aspx

    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Kill Process

    As is often the case, Microsoft don't show every property/method to the full in their examples - and occasionally (like in this case) show things which are over simplified, and thus go against the documentation of those properties.

    The actual documentation for State includes this:
    The object's State property can have a combination of values. For example, if a statement is executing, this property will have a combined value of adStateOpen and adStateExecuting.
    I've seen this happen myself (and it's been an issue on the forums before), so it seems that the example from Microsoft is not entirely safe - but their explanation is fine.

    I guess they simplified the example so that they didn't have to explain bit masking.

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