title: Connecting localhost sql database with OLEDB
body: <p>I have the following code to connect the localhost database with OLEDB using VB.NET. Below are the code:</p>
  
  <pre><code>Imports System.IO
  Imports System.Data
  Imports System.Data.OleDb
  
  Module Module1
  Public conn As OleDbConnection
  
  Public Sub OpenConnection()
  
      conn = New OleDbConnection()
  
      If conn.State = ConnectionState.Closed Then
  
          Try
          conn.ConnectionString = "provider=MySQLProv; Data Source=mydbname; User Id=root; Password=password"
  
           conn.Open()
  
              MsgBox("Connected to DB")
  
  Catch ex As OleDbException
                  MessageBox.Show("Error Connecting to Database")
                  conn.Close()
                  conn.Dispose()
              End Try
          End If
      End Sub
  </code></pre>
  
  <p>When running, the error "The 'MySQLProv' provider is not registered on the local machine." appears. I already installed MySQL Connector Net 6.5.7 and MySQL Connector ODBC 5.3 but Visual Studios says it is not installed. </p>
  
  <p>I also have tried different connection string as below but each of them has error:</p>
  
  <pre><code>            'conn.ConnectionString = "Driver={MySQL};SERVER=localhost;DATABASE=smsengine5;USER=root;PASSWORD=password"
  
              'conn.ConnectionString = "provider=MYSQLOLEDB; Driver={MySQL};SERVER=localhost;DATABASE=mydbname;USER=root;PASSWORD=password"
  
              'conn.ConnectionString = "provider=.NET Framework Data Provider for MySQL;*;Uid=root;Pwd=password;Database=mydbname;"
  
              'conn.ConnectionString = "provider=MySQLProv; Data Source=mydbname; User Id=root; Password=password"
  
              'conn.ConnectionString = "Driver={mysql};Server=localhost;PORT=3306;UI D=root;PWD=password;OPTION=16386"
  
              'conn.ConnectionString = "Provider=&lt;&lt;MySQLProv&gt;&gt;; Location=&lt;&lt;localhost&gt;&gt;; Data Source=&lt;&lt;mydbname&gt;&gt;; USER ID=&lt;&lt;root&gt;&gt;; PASSWORD=&lt;&lt;password&gt;&gt;; option=3;port=33 06;"
  
              'conn.ConnectionString = "Driver={MySQL ODBC 3.51 Driver};Server=localhost Database=mydbname; User=root; Password=password; Optio n=4;"
  
              'conn.ConnectionString = "Provider=MySQLProv.3.9;Location=&lt;&lt;localhost&gt;&gt;;Data Source=&lt;&lt;mydbname&gt;&gt;; USER ID=&lt;&lt;&gt;root&gt;&gt;;Password=&lt;&lt;password&gt;&gt;;port=&lt;&lt;3306&gt;&gt;;"
  
              'conn.ConnectionString = "Provider=MySQL Provider; Data Source=localhost; User ID=root; Password=password; Initial Catalog=mydbname;"
  
              'conn.ConnectionString = "Server=localhost;Database=mydbname;Uid=User;Pwd=mypass; providerName=MySql.Data.MySqlClient"
  
              'conn.ConnectionString = "Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=mydbname; User=root;Password=myPassword;Option=3;"
  
              'conn.ConnectionString = "Provider=SQLOLEDB; Data Source=localhost; Initial Catalog=mydbname; User ID=root; Password=password;"
  
              'conn.ConnectionString = "Data Source=localhost:3306;Database=mydbname;User ID=root; Password=password;"
  </code></pre>
  
  <p>I also done referencing Mysql.Data in my project.</p>
  
  <p>**I do not want to use MySQL Client.</p>
  
  <p>Please help. Thanks</p>