我在Vb.net中使用Mysql连接创建了简单的注册,但是在加载表单时我总是遇到异常错误但在关闭对话框后我的注册表单正在加载并正常工作。我在哪里做错了?以下代码可以帮助我吗?
Public bool2 As Boolean = True
Dim mysqlconnection As MySqlConnection
Dim mysqlconnection3 As MySqlConnection
Private Sub frm_registration_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If IO.File.Exists(Environ("SystemRoot") & "\SMPregistration.ini") Then
bool2 = False
f_main.Show()
Close()
Else
mysqlconnection3 = New MySqlConnection
mysqlconnection3.ConnectionString = "Server=Server;Port=3306; user id=User; password=Password; database=mydatabae"
mysqlconnection3.Open()
Using ds1 As New DataSet()
'########################################
Dim sqlquery3 = "SELECT ID, Registration, Used, CPU FROM activation"
Using command3 As New MySqlCommand()
Using myadapter3 As New MySqlDataAdapter()
Try
command3.Connection = mysqlconnection3
command3.CommandText = sqlquery3
'myadapter3.SelectCommand = command3
myadapter3.Fill(ds1, "activation")
Catch ex As Exception
MsgBox("Error! No connection with database.", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "Error")
End Try
End Using
End Using
Dim br1 As String = GetCPUid()
For Information As Integer = 0 To ds1.Tables(0).Rows.Count - 1
If ds1.Tables(0).Rows(Information).Item(3).ToString <> br1 Then
Else
bool2 = False
f_main.Show()
End If
Next
End Using
mysqlconnection3.Close()
End If
End Sub