Hello to every one,
I've crated simple registration using Mysql connection in Vb.net but I am always getting exception error while form is loading but after closing dialog my registration form is loading and working properly. Where I am doing mistake? Anyone can help me with below code?
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