Type Initialization Exception

zimzon

Member
Joined
Oct 31, 2006
Messages
13
Programming Experience
Beginner
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
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
Case 1045
MsgBox(
"Password not correct.", MsgBoxStyle.Information, "Password Error")
End Select
End Try
MsgBox(myConn.State)
End Sub
End Module


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
MessageBox.Show(​
"Either Username or Password is not entered.", "Login Failed", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly, False)
tries += 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 If
Else
myServerConnect(UsernameTextBox.Text, PasswordTextBox.Text)
End If
End Sub



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?






 
Back
Top