VB.NET - VS.NET 2005
-
I am working on a application that uses the MyApplication_UnhandledException event to basically tell the user that I screwed up somewhere...see below Private Sub MyApplication_UnhandledException(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.UnhandledExceptionEventArgs) Handles Me.UnhandledException MsgBox(e.Exception.Message.ToString) e.ExitApplication = False End Sub My test app that I was working on has 3 controls on it, A menu bar, textbox, and datagrid. The app will take what I have in the textbox aka SQL Query, then use the dataadapter to fill a dataset then bind it to the datagrid. Here is where it gets weird, or at least I have no idea why this happens... First here is my code... I have a SQL class, which takes the query, and connection string and returns a datatable Imports System.Data Imports System.Data.SqlClient Public Class SQL Private pResults As New DataTable Private pQuery As String Private pConnStr As String Public ReadOnly Property Results() As DataTable Get Return pResults End Get End Property Public Sub New(ByVal ConnStr As String, ByVal Query As String) pConnStr = ConnStr pQuery = Query End Sub Public Function ExecuteQuery() As DataTable Dim DBConn As SqlConnection Try DBConn = New SqlConnection(pConnStr) DBConn.Open() Dim adp As New SqlDataAdapter(pQuery, DBConn) adp.Fill(pResults) Return pResults Catch ex As Exception Throw ex Finally DBConn.Close() End Try End Function End Class Also here is my main body of the testForm, the menubar has two items one Parent (File) then a child node of Run with a shortcut key set to Ctrl+R Private Const CONNECTION_STRING As String = "uid=sa;password=SomePassword;initial catalog=SomeDatabase;data source=wwwsql01,1433;connect timeout=15;persist security info=false;network library=dbmssocn" Private Sub RunToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RunToolStripMenuItem.Click RunQuery() End Sub Private Sub RunQuery() Dim qry As New SQL(Me.CONNECTION_STRING, TextBox1.Text) qry.ExecuteQuery() DataGridView1.DataSource = qry.Results End Sub Very simple... If I run it as is and an exception is thrown when I press Ctrl+R while in the textbox, the unh