Results 1 to 16 of 16

Thread: [RESOLVED] Load Event Aborting

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2010
    Posts
    74

    Resolved [RESOLVED] Load Event Aborting

    In a VB.Net 2017 Windows form application, so far I have only a splash form and a main form. When the user clicks a button on the splash form or a ten second timer fires (whichever occurs first) the splash form runs the AllDone() sub, which opens the main form and then closes itself. Here's the relevant code in the splash form:
    Code:
    Private Sub AllDone()
        Timer1.Enabled = False
        frmMain.Show()
        Me.Close()
    End Sub
    Here's the relevant code in the main form:
    Code:
    Imports System.Data.SqlClient
    ...
    Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'display version information
        Me.Text = "Referral Tracking - Version " & My.Application.Info.Version.ToString
        'open database connection
        Conn.ConnectionString = ConnString
        Conn.Open()
        MsgBox("Connection State: " & Conn.State)
    End Sub
    Conn and ConnString are defined in a separate module as follows:
    Code:
    Imports System.Data.SqlClient
    ...
    Public Conn As SqlConnection = New SqlConnection
    Public ConnString As String = "[actual connection string]"
    I've used this approach successfully in other projects. But in this particular project, it doesn't work. When frmMain_Load() runs, only its first two statements execute, then execution returns to AllDone() and the remaining two statements in frmMain_Load() never execute. No error is raised and the connection is not actually opened.

    What am I doing wrong?
    Last edited by dday9; Oct 19th, 2021 at 12:27 PM.

Tags for this Thread

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