这是我的程序的 LoginForm 的代码。当我输入我的详细信息并单击确定时;它只是冻结并且没有错误出现,我该怎么办?
我不知道该怎么做。我检查了单击确定后加载的表单中的问题,这不是问题。我删除了要检查的代码,但它仍然冻结。
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