roblem with MySQL 1.0 .NET Connector using VB.NET Window Form Application
-
Hello all, I found a problem with my database connection. It prompout 2 error message,the following are the 2 message prompout: 1. An unhandled exception of type 'System.ArgumentException' occurred in mysql.data.dll 2. An unhandled exception of type 'System.TypeInitializationException' occurred in Unknown Module. Additional information: The type initializer for "POS_.Module1" threw an exception.
Public ObjMyComm As New MySqlCommand
Public ObjMyRead As MySqlDataReader
Public MyConn As MySqlConnection = New MySqlConnection(Connect())Public strSetKey As String Public ADD\_BINLOG As String = "ADD\_BINLOG" Public Conn As String Public Conn\_localServer As String Public Conn\_localDb As String Public Conn\_localDbUID As String Public Conn\_localDbPassword As String Public Conn\_localDbPort As String
Public Function Connect()
'Data load from App.Config file
Conn_localDb = ConfigurationSettings.AppSettings("MyLocalDb")
Conn_localServer = ConfigurationSettings.AppSettings("MyLocalServer")
Conn_localDbUID = ConfigurationSettings.AppSettings("MyLocalUID")
Conn_localDbPassword = ConfigurationSettings.AppSettings("MyLocalPass")
Conn_localDbPort = ConfigurationSettings.AppSettings("MyLocalPort")Conn = "DATABASE=" & Conn\_localDb & ";DSN=" & Conn\_localDb & ";OPTION=3;PORT=" & Conn\_localDbPort & ";SERVER=" & Conn\_localServer & ";UID=" & Conn\_localDbUID & ";" MessageBox.Show(Conn) Return Conn
End Function
Public Function LoadBlnStartupData(ByVal strSetKey As String)
Dim test As StringTry MessageBox.Show("\*\*\*\* = " & strSetKey & " " & TerminalLocate & " " & TerminalID & " ") MessageBox.Show(TerminalLocate) 'ObjMyComm = New MySqlCommand("SELECT \* FROM pos\_setting WHERE LocationCode=' " & TerminalLocate & " ' AND SettingKey='ADD\_BINLOG' ", MyConn) ObjMyComm = New MySqlCommand("SELECT \* FROM pos\_setting", MyConn) MyConn.Open() ObjMyRead = ObjMyComm.ExecuteReader If ObjMyRead.Read Then test = ObjMyRead.Item(0) MessageBox.Show("This is " & test & "") Else MessageBox.Show("No value") End If MyConn.Close() Catch ex As Exception MessageBox.Show(ex.Message) Finally MyConn.Close() End Try End Function
The 1st Error are poi
-
Hello all, I found a problem with my database connection. It prompout 2 error message,the following are the 2 message prompout: 1. An unhandled exception of type 'System.ArgumentException' occurred in mysql.data.dll 2. An unhandled exception of type 'System.TypeInitializationException' occurred in Unknown Module. Additional information: The type initializer for "POS_.Module1" threw an exception.
Public ObjMyComm As New MySqlCommand
Public ObjMyRead As MySqlDataReader
Public MyConn As MySqlConnection = New MySqlConnection(Connect())Public strSetKey As String Public ADD\_BINLOG As String = "ADD\_BINLOG" Public Conn As String Public Conn\_localServer As String Public Conn\_localDb As String Public Conn\_localDbUID As String Public Conn\_localDbPassword As String Public Conn\_localDbPort As String
Public Function Connect()
'Data load from App.Config file
Conn_localDb = ConfigurationSettings.AppSettings("MyLocalDb")
Conn_localServer = ConfigurationSettings.AppSettings("MyLocalServer")
Conn_localDbUID = ConfigurationSettings.AppSettings("MyLocalUID")
Conn_localDbPassword = ConfigurationSettings.AppSettings("MyLocalPass")
Conn_localDbPort = ConfigurationSettings.AppSettings("MyLocalPort")Conn = "DATABASE=" & Conn\_localDb & ";DSN=" & Conn\_localDb & ";OPTION=3;PORT=" & Conn\_localDbPort & ";SERVER=" & Conn\_localServer & ";UID=" & Conn\_localDbUID & ";" MessageBox.Show(Conn) Return Conn
End Function
Public Function LoadBlnStartupData(ByVal strSetKey As String)
Dim test As StringTry MessageBox.Show("\*\*\*\* = " & strSetKey & " " & TerminalLocate & " " & TerminalID & " ") MessageBox.Show(TerminalLocate) 'ObjMyComm = New MySqlCommand("SELECT \* FROM pos\_setting WHERE LocationCode=' " & TerminalLocate & " ' AND SettingKey='ADD\_BINLOG' ", MyConn) ObjMyComm = New MySqlCommand("SELECT \* FROM pos\_setting", MyConn) MyConn.Open() ObjMyRead = ObjMyComm.ExecuteReader If ObjMyRead.Read Then test = ObjMyRead.Item(0) MessageBox.Show("This is " & test & "") Else MessageBox.Show("No value") End If MyConn.Close() Catch ex As Exception MessageBox.Show(ex.Message) Finally MyConn.Close() End Try End Function
The 1st Error are poi
Hi, Are you sure your connectionstring is correct ? I use the following one without any issues (VS2005):
Private sConnString As String = String.Format("server={0};port=3306;user id={1};password={2};database={3};pooling=false", _
My.Settings.dbserver, My.Settings.dbuser, My.Settings.dbpassword, My.Settings.database)
Private conn As New MySqlConnection(sConnString)
conn.open() -
Hi, Are you sure your connectionstring is correct ? I use the following one without any issues (VS2005):
Private sConnString As String = String.Format("server={0};port=3306;user id={1};password={2};database={3};pooling=false", _
My.Settings.dbserver, My.Settings.dbuser, My.Settings.dbpassword, My.Settings.database)
Private conn As New MySqlConnection(sConnString)
conn.open()Hello Noctris, I doesn't found any problem with my connection string as I have create a udl file to check if I get the right connection but it shows me the connection string is correct. I'm using VS 2003 .NET. Is that problem cause by this version of Visual Studio? I heard ppl said that is alot of problem in this version of Visual Studio. Anyone have other suggestion for this solution? Regards Drex
-
Hello Noctris, I doesn't found any problem with my connection string as I have create a udl file to check if I get the right connection but it shows me the connection string is correct. I'm using VS 2003 .NET. Is that problem cause by this version of Visual Studio? I heard ppl said that is alot of problem in this version of Visual Studio. Anyone have other suggestion for this solution? Regards Drex
Hmm.. couldn't tell you that.. i never used the Mysql.NET connector in VS2003.. always 2005 at the last part in your "catch ex to exception", can you change to MessageBox.Show(Ex.ToString) and this ? The actual error will give a lot more information about the issue.
-
Hello all, I found a problem with my database connection. It prompout 2 error message,the following are the 2 message prompout: 1. An unhandled exception of type 'System.ArgumentException' occurred in mysql.data.dll 2. An unhandled exception of type 'System.TypeInitializationException' occurred in Unknown Module. Additional information: The type initializer for "POS_.Module1" threw an exception.
Public ObjMyComm As New MySqlCommand
Public ObjMyRead As MySqlDataReader
Public MyConn As MySqlConnection = New MySqlConnection(Connect())Public strSetKey As String Public ADD\_BINLOG As String = "ADD\_BINLOG" Public Conn As String Public Conn\_localServer As String Public Conn\_localDb As String Public Conn\_localDbUID As String Public Conn\_localDbPassword As String Public Conn\_localDbPort As String
Public Function Connect()
'Data load from App.Config file
Conn_localDb = ConfigurationSettings.AppSettings("MyLocalDb")
Conn_localServer = ConfigurationSettings.AppSettings("MyLocalServer")
Conn_localDbUID = ConfigurationSettings.AppSettings("MyLocalUID")
Conn_localDbPassword = ConfigurationSettings.AppSettings("MyLocalPass")
Conn_localDbPort = ConfigurationSettings.AppSettings("MyLocalPort")Conn = "DATABASE=" & Conn\_localDb & ";DSN=" & Conn\_localDb & ";OPTION=3;PORT=" & Conn\_localDbPort & ";SERVER=" & Conn\_localServer & ";UID=" & Conn\_localDbUID & ";" MessageBox.Show(Conn) Return Conn
End Function
Public Function LoadBlnStartupData(ByVal strSetKey As String)
Dim test As StringTry MessageBox.Show("\*\*\*\* = " & strSetKey & " " & TerminalLocate & " " & TerminalID & " ") MessageBox.Show(TerminalLocate) 'ObjMyComm = New MySqlCommand("SELECT \* FROM pos\_setting WHERE LocationCode=' " & TerminalLocate & " ' AND SettingKey='ADD\_BINLOG' ", MyConn) ObjMyComm = New MySqlCommand("SELECT \* FROM pos\_setting", MyConn) MyConn.Open() ObjMyRead = ObjMyComm.ExecuteReader If ObjMyRead.Read Then test = ObjMyRead.Item(0) MessageBox.Show("This is " & test & "") Else MessageBox.Show("No value") End If MyConn.Close() Catch ex As Exception MessageBox.Show(ex.Message) Finally MyConn.Close() End Try End Function
The 1st Error are poi
-
Hello all, I found a problem with my database connection. It prompout 2 error message,the following are the 2 message prompout: 1. An unhandled exception of type 'System.ArgumentException' occurred in mysql.data.dll 2. An unhandled exception of type 'System.TypeInitializationException' occurred in Unknown Module. Additional information: The type initializer for "POS_.Module1" threw an exception.
Public ObjMyComm As New MySqlCommand
Public ObjMyRead As MySqlDataReader
Public MyConn As MySqlConnection = New MySqlConnection(Connect())Public strSetKey As String Public ADD\_BINLOG As String = "ADD\_BINLOG" Public Conn As String Public Conn\_localServer As String Public Conn\_localDb As String Public Conn\_localDbUID As String Public Conn\_localDbPassword As String Public Conn\_localDbPort As String
Public Function Connect()
'Data load from App.Config file
Conn_localDb = ConfigurationSettings.AppSettings("MyLocalDb")
Conn_localServer = ConfigurationSettings.AppSettings("MyLocalServer")
Conn_localDbUID = ConfigurationSettings.AppSettings("MyLocalUID")
Conn_localDbPassword = ConfigurationSettings.AppSettings("MyLocalPass")
Conn_localDbPort = ConfigurationSettings.AppSettings("MyLocalPort")Conn = "DATABASE=" & Conn\_localDb & ";DSN=" & Conn\_localDb & ";OPTION=3;PORT=" & Conn\_localDbPort & ";SERVER=" & Conn\_localServer & ";UID=" & Conn\_localDbUID & ";" MessageBox.Show(Conn) Return Conn
End Function
Public Function LoadBlnStartupData(ByVal strSetKey As String)
Dim test As StringTry MessageBox.Show("\*\*\*\* = " & strSetKey & " " & TerminalLocate & " " & TerminalID & " ") MessageBox.Show(TerminalLocate) 'ObjMyComm = New MySqlCommand("SELECT \* FROM pos\_setting WHERE LocationCode=' " & TerminalLocate & " ' AND SettingKey='ADD\_BINLOG' ", MyConn) ObjMyComm = New MySqlCommand("SELECT \* FROM pos\_setting", MyConn) MyConn.Open() ObjMyRead = ObjMyComm.ExecuteReader If ObjMyRead.Read Then test = ObjMyRead.Item(0) MessageBox.Show("This is " & test & "") Else MessageBox.Show("No value") End If MyConn.Close() Catch ex As Exception MessageBox.Show(ex.Message) Finally MyConn.Close() End Try End Function
The 1st Error are poi