Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. roblem with MySQL 1.0 .NET Connector using VB.NET Window Form Application

roblem with MySQL 1.0 .NET Connector using VB.NET Window Form Application

Scheduled Pinned Locked Moved Visual Basic
helpcsharpdatabasemysql
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    drexler_kk
    wrote on last edited by
    #1

    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 String

        Try
            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

    N S 3 Replies Last reply
    0
    • D drexler_kk

      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 String

          Try
              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

      N Offline
      N Offline
      Noctris
      wrote on last edited by
      #2

      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()

      D 1 Reply Last reply
      0
      • N Noctris

        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()

        D Offline
        D Offline
        drexler_kk
        wrote on last edited by
        #3

        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

        N 1 Reply Last reply
        0
        • D drexler_kk

          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

          N Offline
          N Offline
          Noctris
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • D drexler_kk

            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 String

                Try
                    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

            S Offline
            S Offline
            SteveNY
            wrote on last edited by
            #5

            It def. seems like your conn string is badly formed. Try a simple app first. Might have luck using this tutorial also: www.vbmysql.com[^]

            1 Reply Last reply
            0
            • D drexler_kk

              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 String

                  Try
                      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

              S Offline
              S Offline
              SteveNY
              wrote on last edited by
              #6

              To add, there is a vb.net example that gets installed with the .net connector, it is in C:\Program Files\MySQL\MySQL Connector Net 5.1.6\Samples\Table Editor\vb You can use that as a guide.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups