0

これは、私のプログラムの LoginForm のコードです。詳細を入力して [OK] をクリックすると、フリーズするだけで、エラーは表示されません。どうすればよいですか?

どうすればいいのかわかりません。OKをクリックした後に読み込まれるフォームに問題があることを確認しましたが、問題はありませんでした。チェックするコードを削除しましたが、まだフリーズしています。

           Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
    Dim Servtxt As String
    Dim Usertxt As String
    Dim Passtxt As String
    Dim tbltxt As String
    Dim FILE_NAME As String = "C:/Program Files/Business Elements/Dashboard System Files/LoginServerDAT.txt"
    Try
        Dim lines = System.IO.File.ReadAllLines("C:/Program Files/Business Elements/Dashboard System Files/LoginServerDAT.txt")
        Servtxt = lines(0)
        Usertxt = lines(1)
        Passtxt = lines(2)
        tbltxt = lines(3)
    Catch ex As Exception
        MessageBox.Show("Error! The server configuration file does not exist. Please setup the server information and save it.", "Woops, something went wrong...", MessageBoxButtons.OK, MessageBoxIcon.Error)
    End Try
    'Open Connection
    Dim da As MySqlDataAdapter = New MySqlDataAdapter
    Dim SQLConnection As MySqlConnection = New MySqlConnection
    Dim ServerString As String = "server=" & Servtxt & ";user id=" & Usertxt & ";password=" & Passtxt & ";database=" & tbltxt
    SQLConnection.ConnectionString = ServerString
    Dim MsgResponse As MsgBoxResult
    Try
        SQLConnection.Open()
    Catch ex As Exception
        MsgResponse = MessageBox.Show("Connection could not be established to the server, but you can still run in offline mode. If you want to do so then click YES. If otherwise, click NO", "Woops! Something went wrong..", MessageBoxButtons.YesNo)
        If MsgResponse = MsgBoxResult.Yes Then
            Home.Show()
            Home.ConnectedLabel.Text = "Offline Mode. See website for troubleshooting tips."
            Home.ConnectedLabel.ForeColor = Color.Red
            Home.CurrentUser.Text = ""
            Home.ToolStripStatusLabel1.Visible = False
            Me.Close()
        Else
            Me.Close()
        End If
    End Try
    'Sign in..
    If SQLConnection.State = ConnectionState.Open = True Then
        Dim sqlquery = "SELECT * From Users Where Username='" & UsernameTextBox.Text & "' AND Password='" & PasswordTextBox.Text & "'"
        Dim command As New MySqlCommand
        command.Connection = SQLConnection
        command.CommandText = sqlquery
        da.SelectCommand = command
        Dim mydata As MySqlDataReader
        mydata = command.ExecuteReader
        If mydata.HasRows = 0 Then
            MessageBox.Show("Error! Incorrect Login Details. Please contact your Administrator for assistance.")
        Else
            'Check Level..
            CheckAccessLevel()

        End If
    End If
End Sub
4

0 に答える 0