vb.net表格不会启动,只会关闭

时间:2018-10-21 01:15:47

标签: vb.net

我将我的第一个表单设置为登录页面,但是当我启动它时,它将立即关闭

Private Sub login_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim ToolTip1 As New ToolTip()
    ToolTip1.AutoPopDelay = 5000
    ToolTip1.InitialDelay = 1000
    ToolTip1.ReshowDelay = 500
    ToolTip1.ShowAlways = True
    ToolTip1.SetToolTip(Me.txt_pword, "Enter password here!")
    ToolTip1.SetToolTip(Me.txt_username, "Enter username here!")
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btn_login2.Click
    dbconn = New SqlConnection
    dbconn.ConnectionString = ("Data Source=JENELIE\SQLEXPRESS;Initial Catalog=LDESfeeding_DB;User ID=sa;Password=Jenelie19")
    Dim reader As SqlDataReader
    Try
        dbconn.Open()
        Dim sql As String
        sql = "select * from auth_pword where Password = '" & txt_pword.Text & "' and username = '" & txt_username.Text & "' "
        dbcomm = New SqlCommand(sql, dbconn)
        reader = dbcomm.ExecuteReader
        Dim ctr As Integer
        ctr = 0
        While reader.Read
            ctr = ctr + 1
        End While
        If ctr = 1 Then
            MessageBox.Show("Login Successful!")
            homepage.Show()
            Me.Close()
        Else
            MessageBox.Show("Incorrect Username or Password!")
        End If
        dbconn.Close()
    Catch ex As SqlException
        MessageBox.Show(ex.Message)
    End Try
End Sub

结束类 这就是该形式的整个代码。我不知道是什么导致它关闭。 我试图将.Close()更改为.Hide(),但仍然没有任何变化。

0 个答案:

没有答案