How to end a program and bring another one in front

BNE Sys 61 Reputation points
2022-08-05T21:20:06.84+00:00

The below code queries the SQL server and fetches the data successfully (thanks very much to JiachenLiMFST-9349 for amazing help). I need this program to kill the notepad and bring the excel in front if the program query returns with any result (in this case, the word is "CardAccess").

Public Class Inventory  
    Public SQL As New SQLControl()  
    Public Sub LoadGrid(Optional Query As String = "")  
        If Query = "" Then  
            SQL.ExecQuery("SELECT TOP 100 * FROM VReview WHERE Text LIKE '%CardAccess%' Order By [UTCTimeInserted] Desc;")  
        Else  
            SQL.ExecQuery(Query)  
        End If  
        ' ERROR HANDLING  
        If SQL.HasException(True) Then  
            Timer1.Stop()  
            KillHungProcess("Notepad.exe")  
            StartOrShowProcess("Excel.exe")  
        End If  
  
        dgvData.DataSource = SQL.DBDT  
    End Sub  
  
    Private Sub Inventory_Load(sender As Object, e As EventArgs) Handles MyBase.Load  
        MdiParent = Form1  
        LoadGrid()  
    End Sub  
  
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click  
        Timer1.Interval = 500  
        Timer1.Start()  
    End Sub  
  
  
    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick  
        LoadGrid()  
    End Sub  
  
    Public Sub KillHungProcess(processName As String)  
        Dim psi As ProcessStartInfo = New ProcessStartInfo  
        psi.Arguments = "/im " & processName & " /f"  
        psi.FileName = "taskkill"  
        psi.WindowStyle = ProcessWindowStyle.Hidden  
        Dim p As Process = New Process()  
        p.StartInfo = psi  
        p.Start()  
    End Sub  
#Region "DLL Imports"  
    <System.Runtime.InteropServices.DllImport("User32.dll")>  
    Private Shared Function SetForegroundWindow(handle As IntPtr) As Boolean  
    End Function  
  
    <System.Runtime.InteropServices.DllImport("User32.dll")>  
    Private Shared Function ShowWindow(handle As IntPtr, nCmdShow As Integer) As Boolean  
    End Function  
    <System.Runtime.InteropServices.DllImport("User32.dll")>  
    Private Shared Function IsIconic(handle As IntPtr) As Boolean  
    End Function  
#End Region  
    Private Sub StartOrShowProcess(ByVal strProcessName As String)  
        Try  
            Dim handle As IntPtr  
            Dim proc As Process() = Process.GetProcessesByName(strProcessName)  
            If proc.Count > 0 Then  
                For Each procP As Process In proc  
                    handle = procP.MainWindowHandle  
                    If handle <> 0 AndAlso IsIconic(handle) Then 'Do we have a handle and is it minimized?  
                        ShowWindow(handle, 9)  
                        SetForegroundWindow(handle)  
                    End If  
                Next  
            Else 'Not running or started...  
                Process.Start(strProcessName)  
            End If  
  
        Catch ex As Exception  
            'Handle your error...  
        End Try  
    End Sub  
  
End Class  
Developer technologies | VB
{count} votes

Answer accepted by question author
  1. RLWA32 51,366 Reputation points
    2022-08-08T09:36:07.613+00:00

    Replace StartorShowProcesses with the following -

    Private Sub BringToTop(name As String)  
        Try  
            Dim procs() As Process = Process.GetProcessesByName(name)  
            Dim thisproc As Process = Process.GetCurrentProcess()  
            Dim sess = thisproc.SessionId  
            For Each proc In procs  
                If proc.SessionId = sess Then  
                    Dim handle As IntPtr = proc.MainWindowHandle  
                    If handle <> IntPtr.Zero Then  
                        If SetWindowPos(handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE) = False Then  
                            Throw New Win32Exception(Marshal.GetLastWin32Error())  
                        End If  
                    End If  
                End If  
            Next  
        Catch ex As Exception  
            MessageBox.Show(ex.Message)  
        End Try  
    
    End Sub  
    
    
      
    

    You'll also need to include this -

        <DllImport("User32.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall, SetLastError:=True)>  
        Private Shared Function SetWindowPos(hwnd As IntPtr,  
                                             hwndAfter As IntPtr,  
                                             X As Integer,  
                                             Y As Integer,  
                                             cx As Integer,  
                                             cy As Integer,  
                                             flags As UInteger) As Boolean  
        End Function  
      
        Dim SWP_NOSIZE As UInteger = &H1  
        Dim SWP_NOMOVE As UInteger = &H2  
        Dim SWP_NOZORDER As UInteger = &H4  
        Dim SWP_NOREDRAW As UInteger = &H8  
        Dim SWP_NOACTIVATE As UInteger = &H10  
        Dim SWP_FRAMECHANGED As UInteger = &H20 'The frame changed: send WM_NCCALCSIZE  
        Dim SWP_SHOWWINDOW As UInteger = &H40  
        Dim SWP_HIDEWINDOW As UInteger = &H80  
        Dim SWP_NOCOPYBITS As UInteger = &H100  
        Dim SWP_NOOWNERZORDER As UInteger = &H200 'Don't do owner Z ordering  
        Dim SWP_NOSENDCHANGING As UInteger = &H400 '/Don't send WM_WINDOWPOSCHANGING  
      
        Dim SWP_DRAWFRAME As UInteger = SWP_FRAMECHANGED  
        Dim SWP_NOREPOSITION As UInteger = SWP_NOOWNERZORDER  
      
        Dim SWP_DEFERERASE As UInteger = &H2000  
        Dim SWP_ASYNCWINDOWPOS As UInteger = &H4000  
      
      
        Dim HWND_TOP As IntPtr = 0  
        Dim HWND_BOTTOM As IntPtr = 1  
        Dim HWND_TOPMOST As IntPtr = -1  
        Dim HWND_NOTOPMOST As IntPtr = -2  
      
    

    and

       Imports System.ComponentModel  
    
    0 comments No comments

4 additional answers

Sort by: Most helpful
  1. BNE Sys 61 Reputation points
    2022-08-08T20:18:57.603+00:00

    Not sure if I placed your codes to the correct spots but I received the below screenshot, sir.

    Imports System.ComponentModel  
    Public Class Inventory  
        Public SQL As New SQLControl()  
        Public Sub LoadGrid(Optional Query As String = "")  
            If Query = "" Then  
                SQL.ExecQuery("SELECT TOP 100 * FROM VReview WHERE Text LIKE '%Access%' Order By [UTCTimeInserted] Desc;")  
            Else  
                SQL.ExecQuery(Query)  
            End If  
            ' ERROR HANDLING  
            If SQL.HasException(True) Then  
                Timer1.Stop()  
                KillHungProcess("Notepad.exe")  
                StartOrShowProcess("Excel.exe")  
            End If  
      
            dgvData.DataSource = SQL.DBDT  
        End Sub  
      
        Private Sub Inventory_Load(sender As Object, e As EventArgs) Handles MyBase.Load  
            MdiParent = Form1  
            LoadGrid()  
        End Sub  
      
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click  
            Timer1.Interval = 500  
            Timer1.Start()  
        End Sub  
      
      
        Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick  
            LoadGrid()  
        End Sub  
      
        Public Sub KillHungProcess(processName As String)  
            Dim psi As ProcessStartInfo = New ProcessStartInfo  
            psi.Arguments = "/im " & processName & " /f"  
            psi.FileName = "taskkill"  
            psi.WindowStyle = ProcessWindowStyle.Hidden  
            Dim p As Process = New Process()  
            p.StartInfo = psi  
            p.Start()  
        End Sub  
    #Region "DLL Imports"  
        <System.Runtime.InteropServices.DllImport("User32.dll")>  
        Private Shared Function SetForegroundWindow(handle As IntPtr) As Boolean  
        End Function  
      
        <System.Runtime.InteropServices.DllImport("User32.dll")>  
        Private Shared Function ShowWindow(handle As IntPtr, nCmdShow As Integer) As Boolean  
        End Function  
        <System.Runtime.InteropServices.DllImport("User32.dll")>  
        Private Shared Function IsIconic(handle As IntPtr) As Boolean  
        End Function  
    #End Region  
        Private Sub BringToTop(name As String)  
            Try  
                Dim procs() As Process = Process.GetProcessesByName(name)  
                Dim thisproc As Process = Process.GetCurrentProcess()  
                Dim sess = thisproc.SessionId  
                For Each proc In procs  
                    If proc.SessionId = sess Then  
                        Dim handle As IntPtr = proc.MainWindowHandle  
                        If handle <> IntPtr.Zero Then  
                            If SetWindowPos(handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE) = False Then  
                                Throw New Win32Exception(Marshal.GetLastWin32Error())  
                            End If  
                        End If  
                    End If  
                Next  
            Catch ex As Exception  
                MessageBox.Show(ex.Message)  
            End Try  
        End Sub  
      
        <DllImport("User32.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall, SetLastError:=True)>  
        Private Shared Function SetWindowPos(hwnd As IntPtr,  
                                         hwndAfter As IntPtr,  
                                         X As Integer,  
                                         Y As Integer,  
                                         cx As Integer,  
                                         cy As Integer,  
                                         flags As UInteger) As Boolean  
        End Function  
      
        Dim SWP_NOSIZE As UInteger = &H1  
        Dim SWP_NOMOVE As UInteger = &H2  
        Dim SWP_NOZORDER As UInteger = &H4  
        Dim SWP_NOREDRAW As UInteger = &H8  
        Dim SWP_NOACTIVATE As UInteger = &H10  
        Dim SWP_FRAMECHANGED As UInteger = &H20 'The frame changed: send WM_NCCALCSIZE  
        Dim SWP_SHOWWINDOW As UInteger = &H40  
        Dim SWP_HIDEWINDOW As UInteger = &H80  
        Dim SWP_NOCOPYBITS As UInteger = &H100  
        Dim SWP_NOOWNERZORDER As UInteger = &H200 'Don't do owner Z ordering  
        Dim SWP_NOSENDCHANGING As UInteger = &H400 '/Don't send WM_WINDOWPOSCHANGING  
      
        Dim SWP_DRAWFRAME As UInteger = SWP_FRAMECHANGED  
        Dim SWP_NOREPOSITION As UInteger = SWP_NOOWNERZORDER  
      
        Dim SWP_DEFERERASE As UInteger = &H2000  
        Dim SWP_ASYNCWINDOWPOS As UInteger = &H4000  
      
      
        Dim HWND_TOP As IntPtr = 0  
        Dim HWND_BOTTOM As IntPtr = 1  
        Dim HWND_TOPMOST As IntPtr = -1  
        Dim HWND_NOTOPMOST As IntPtr = -2  
      
    End Class  
    

    229341-screenshot.png


  2. BNE Sys 61 Reputation points
    2022-08-08T22:21:08.937+00:00

    Thank you, sir. No error this time but also no action. I was able to see the log entries but the program did not bring the excel in front nor close the notepad.

    Imports System.ComponentModel  
    Imports System.Runtime.InteropServices  
    Public Class Inventory  
        Public SQL As New SQLControl()  
        Public Sub LoadGrid(Optional Query As String = "")  
            If Query = "" Then  
                SQL.ExecQuery("SELECT TOP 100 * FROM VReview WHERE Text LIKE '%Access%' Order By [UTCTimeInserted] Desc;")  
            Else  
                SQL.ExecQuery(Query)  
            End If  
            ' ERROR HANDLING  
            If SQL.HasException(True) Then  
                Timer1.Stop()  
                KillHungProcess("Notepad.exe")  
                BringToTop("Excel.exe")  
            End If  
      
            dgvData.DataSource = SQL.DBDT  
        End Sub  
      
        Private Sub Inventory_Load(sender As Object, e As EventArgs) Handles MyBase.Load  
            MdiParent = Form1  
            LoadGrid()  
        End Sub  
      
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click  
            Timer1.Interval = 500  
            Timer1.Start()  
        End Sub  
      
      
        Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick  
            LoadGrid()  
        End Sub  
      
        Public Sub KillHungProcess(processName As String)  
            Dim psi As ProcessStartInfo = New ProcessStartInfo  
            psi.Arguments = "/im " & processName & " /f"  
            psi.FileName = "taskkill"  
            psi.WindowStyle = ProcessWindowStyle.Hidden  
            Dim p As Process = New Process()  
            p.StartInfo = psi  
            p.Start()  
        End Sub  
    #Region "DLL Imports"  
        <System.Runtime.InteropServices.DllImport("User32.dll")>  
        Private Shared Function SetForegroundWindow(handle As IntPtr) As Boolean  
        End Function  
      
        <System.Runtime.InteropServices.DllImport("User32.dll")>  
        Private Shared Function ShowWindow(handle As IntPtr, nCmdShow As Integer) As Boolean  
        End Function  
        <System.Runtime.InteropServices.DllImport("User32.dll")>  
        Private Shared Function IsIconic(handle As IntPtr) As Boolean  
        End Function  
    #End Region  
        Private Sub BringToTop(name As String)  
            Try  
                Dim procs() As Process = Process.GetProcessesByName(name)  
                Dim thisproc As Process = Process.GetCurrentProcess()  
                Dim sess = thisproc.SessionId  
                For Each proc In procs  
                    If proc.SessionId = sess Then  
                        Dim handle As IntPtr = proc.MainWindowHandle  
                        If handle <> IntPtr.Zero Then  
                            If SetWindowPos(handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE) = False Then  
                                Throw New Win32Exception(Marshal.GetLastWin32Error())  
                            End If  
                        End If  
                    End If  
                Next  
            Catch ex As Exception  
                MessageBox.Show(ex.Message)  
            End Try  
        End Sub  
      
        <DllImport("User32.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall, SetLastError:=True)>  
        Private Shared Function SetWindowPos(hwnd As IntPtr,  
                                         hwndAfter As IntPtr,  
                                         X As Integer,  
                                         Y As Integer,  
                                         cx As Integer,  
                                         cy As Integer,  
                                         flags As UInteger) As Boolean  
        End Function  
      
        Dim SWP_NOSIZE As UInteger = &H1  
        Dim SWP_NOMOVE As UInteger = &H2  
        Dim SWP_NOZORDER As UInteger = &H4  
        Dim SWP_NOREDRAW As UInteger = &H8  
        Dim SWP_NOACTIVATE As UInteger = &H10  
        Dim SWP_FRAMECHANGED As UInteger = &H20 'The frame changed: send WM_NCCALCSIZE  
        Dim SWP_SHOWWINDOW As UInteger = &H40  
        Dim SWP_HIDEWINDOW As UInteger = &H80  
        Dim SWP_NOCOPYBITS As UInteger = &H100  
        Dim SWP_NOOWNERZORDER As UInteger = &H200 'Don't do owner Z ordering  
        Dim SWP_NOSENDCHANGING As UInteger = &H400 '/Don't send WM_WINDOWPOSCHANGING  
      
        Dim SWP_DRAWFRAME As UInteger = SWP_FRAMECHANGED  
        Dim SWP_NOREPOSITION As UInteger = SWP_NOOWNERZORDER  
      
        Dim SWP_DEFERERASE As UInteger = &H2000  
        Dim SWP_ASYNCWINDOWPOS As UInteger = &H4000  
      
      
        Dim HWND_TOP As IntPtr = 0  
        Dim HWND_BOTTOM As IntPtr = 1  
        Dim HWND_TOPMOST As IntPtr = -1  
        Dim HWND_NOTOPMOST As IntPtr = -2  
      
    End Class  
    

  3. BNE Sys 61 Reputation points
    2022-08-09T00:41:31.26+00:00

    Sorry sir, I thought I followed the instructions but I realised instead of making BringToTop("excel") I made BringToTop("Excel.exe") ; however still not working. What am I missing here?

    Imports System.ComponentModel  
    Imports System.Runtime.InteropServices  
    Public Class Inventory  
        Public SQL As New SQLControl()  
        Public Sub LoadGrid(Optional Query As String = "")  
            If Query = "" Then  
                SQL.ExecQuery("SELECT TOP 100 * FROM VReview WHERE Text LIKE '%Access%' Order By [UTCTimeInserted] Desc;")  
            Else  
                SQL.ExecQuery(Query)  
            End If  
            ' ERROR HANDLING  
            If SQL.HasException(True) Then  
                Timer1.Stop()  
                KillHungProcess("Notepad.exe")  
                BringToTop("excel")  
            End If  
      
            dgvData.DataSource = SQL.DBDT  
        End Sub  
      
        Private Sub Inventory_Load(sender As Object, e As EventArgs) Handles MyBase.Load  
            MdiParent = Form1  
            LoadGrid()  
        End Sub  
      
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click  
            Timer1.Interval = 500  
            Timer1.Start()  
        End Sub  
      
      
        Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick  
            LoadGrid()  
        End Sub  
      
        Public Sub KillHungProcess(processName As String)  
            Dim psi As ProcessStartInfo = New ProcessStartInfo  
            psi.Arguments = "/im " & processName & " /f"  
            psi.FileName = "taskkill"  
            psi.WindowStyle = ProcessWindowStyle.Hidden  
            Dim p As Process = New Process()  
            p.StartInfo = psi  
            p.Start()  
        End Sub  
    #Region "DLL Imports"  
        <System.Runtime.InteropServices.DllImport("User32.dll")>  
        Private Shared Function SetForegroundWindow(handle As IntPtr) As Boolean  
        End Function  
      
        <System.Runtime.InteropServices.DllImport("User32.dll")>  
        Private Shared Function ShowWindow(handle As IntPtr, nCmdShow As Integer) As Boolean  
        End Function  
        <System.Runtime.InteropServices.DllImport("User32.dll")>  
        Private Shared Function IsIconic(handle As IntPtr) As Boolean  
        End Function  
    #End Region  
        Private Sub BringToTop(name As String)  
            Try  
                Dim procs() As Process = Process.GetProcessesByName(name)  
                Dim thisproc As Process = Process.GetCurrentProcess()  
                Dim sess = thisproc.SessionId  
                For Each proc In procs  
                    If proc.SessionId = sess Then  
                        Dim handle As IntPtr = proc.MainWindowHandle  
                        If handle <> IntPtr.Zero Then  
                            If SetWindowPos(handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE) = False Then  
                                Throw New Win32Exception(Marshal.GetLastWin32Error())  
                            End If  
                        End If  
                    End If  
                Next  
            Catch ex As Exception  
                MessageBox.Show(ex.Message)  
            End Try  
        End Sub  
      
        <DllImport("User32.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall, SetLastError:=True)>  
        Private Shared Function SetWindowPos(hwnd As IntPtr,  
                                         hwndAfter As IntPtr,  
                                         X As Integer,  
                                         Y As Integer,  
                                         cx As Integer,  
                                         cy As Integer,  
                                         flags As UInteger) As Boolean  
        End Function  
      
        Dim SWP_NOSIZE As UInteger = &H1  
        Dim SWP_NOMOVE As UInteger = &H2  
        Dim SWP_NOZORDER As UInteger = &H4  
        Dim SWP_NOREDRAW As UInteger = &H8  
        Dim SWP_NOACTIVATE As UInteger = &H10  
        Dim SWP_FRAMECHANGED As UInteger = &H20 'The frame changed: send WM_NCCALCSIZE  
        Dim SWP_SHOWWINDOW As UInteger = &H40  
        Dim SWP_HIDEWINDOW As UInteger = &H80  
        Dim SWP_NOCOPYBITS As UInteger = &H100  
        Dim SWP_NOOWNERZORDER As UInteger = &H200 'Don't do owner Z ordering  
        Dim SWP_NOSENDCHANGING As UInteger = &H400 '/Don't send WM_WINDOWPOSCHANGING  
      
        Dim SWP_DRAWFRAME As UInteger = SWP_FRAMECHANGED  
        Dim SWP_NOREPOSITION As UInteger = SWP_NOOWNERZORDER  
      
        Dim SWP_DEFERERASE As UInteger = &H2000  
        Dim SWP_ASYNCWINDOWPOS As UInteger = &H4000  
      
      
        Dim HWND_TOP As IntPtr = 0  
        Dim HWND_BOTTOM As IntPtr = 1  
        Dim HWND_TOPMOST As IntPtr = -1  
        Dim HWND_NOTOPMOST As IntPtr = -2  
      
    End Class  
    

  4. BNE Sys 61 Reputation points
    2022-08-09T21:47:07.007+00:00

    'SQLQuerier.exe' (CoreCLR: DefaultDomain): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Private.CoreLib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Users\catone\source\repos\SQLQuerier\bin\Debug\net6.0-windows\SQLQuerier.dll'. Symbols loaded.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\6.0.7\Microsoft.VisualBasic.Forms.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\6.0.7\System.Windows.Forms.Primitives.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'c:\program files\microsoft visual studio\2022\enterprise\common7\ide\commonextensions\microsoft\hotreload\Microsoft.Extensions.DotNetDeltaApplier.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.IO.Pipes.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Linq.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Collections.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Console.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Threading.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Threading.Overlapped.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Security.AccessControl.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Security.Principal.Windows.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Runtime.InteropServices.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Security.Claims.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\Microsoft.Win32.Primitives.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Runtime.Loader.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\6.0.7\System.Windows.Forms.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Collections.Concurrent.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Diagnostics.TraceSource.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.ComponentModel.Primitives.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Drawing.Primitives.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Collections.Specialized.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Threading.Thread.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.ComponentModel.EventBasedAsync.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.ComponentModel.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\6.0.7\System.Drawing.Common.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\6.0.7\Accessibility.dll'. Module was built without symbols.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.ComponentModel.TypeConverter.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\Microsoft.VisualBasic.Core.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\6.0.7\Microsoft.Win32.SystemEvents.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Numerics.Vectors.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Memory.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Collections.NonGeneric.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Users\catone\source\repos\SQLQuerier\bin\Debug\net6.0-windows\runtimes\win\lib\netcoreapp2.1\System.Data.SqlClient.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Data.Common.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Transactions.Local.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Threading.Tasks.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Diagnostics.DiagnosticSource.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Diagnostics.Tracing.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\PrivateAssemblies\Runtime\Microsoft.VisualStudio.Debugger.Runtime.NetCoreApp.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\netstandard.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\IntelliTrace\Microsoft.IntelliTrace.TelemetryObserver.Common.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\IntelliTrace\Microsoft.IntelliTrace.TelemetryObserver.CoreClr.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Reflection.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Reflection.Extensions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Threading.Timer.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Xml.ReaderWriter.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Private.Xml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Runtime.Extensions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Threading.ThreadPool.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Text.Encoding.CodePages.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Resources.ResourceManager.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Buffers.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Diagnostics.Process.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Runtime.Numerics.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.Private.Uri.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'SQLQuerier.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.7\System.ObjectModel.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    The program '[10128] SQLQuerier.exe: Program Trace' has exited with code 0 (0x0).
    The program '[10128] SQLQuerier.exe' has exited with code 4294967295 (0xffffffff).


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.