i have the following code and get above mentioned error at run time.
in Module
-------------
Imports MySql
Imports MySql.Data
Imports MySql.Data.MySqlClient
Module Module1
in Form
--------
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
as soon as, click the "OK" button the error dialog box come with the title "Type Initialization Exception was unhandled"
What am i made wrong in code?
in Module
-------------
Imports MySql
Imports MySql.Data
Imports MySql.Data.MySqlClient
Module Module1
Dim Connection As String
Public myConn As New MySql.Data.MySqlClient.MySqlConnection(Connection)
Friend Sub myServerConnect(ByVal userr As String, ByVal passs As String)
Connection = "Database=nuke;User id=" + userr + "root;Password=" + passs + ";Data Source=localhost"
MsgBox(Connection)
Try
myConn.Open()
Catch ex As MySqlException
MsgBox(ex.Message)
MsgBox(ex.Number)
Select Case ex.Number
End ModulePublic myConn As New MySql.Data.MySqlClient.MySqlConnection(Connection)
Friend Sub myServerConnect(ByVal userr As String, ByVal passs As String)
Connection = "Database=nuke;User id=" + userr + "root;Password=" + passs + ";Data Source=localhost"
MsgBox(Connection)
Try
myConn.Open()
Catch ex As MySqlException
MsgBox(ex.Message)
MsgBox(ex.Number)
Select Case ex.Number
Case 1045
MsgBox("Password not correct.", MsgBoxStyle.Information, "Password Error")
End Select
End TryMsgBox("Password not correct.", MsgBoxStyle.Information, "Password Error")
End Select
MsgBox(myConn.State)
End Sub
in Form
--------
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
'Checks login attemps (maximum 3 login atempts only allowed)
Static tries As Integer = 1
If Me.PasswordTextBox.Text = Nothing Or Me.UsernameTextBox.Text = Nothing Then
End SubStatic tries As Integer = 1
If Me.PasswordTextBox.Text = Nothing Or Me.UsernameTextBox.Text = Nothing Then
MessageBox.Show(
"Either Username or Password is not entered.", "Login Failed", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly, False)
tries += 1
Elsetries += 1
If tries > 3 Then
MessageBox.Show(
"Your login attempt are over.", "Login Failed", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly, False)
CloseApp()
End IfCloseApp()
myServerConnect(UsernameTextBox.Text, PasswordTextBox.Text)
End If
as soon as, click the "OK" button the error dialog box come with the title "Type Initialization Exception was unhandled"
What am i made wrong in code?