title: WHERE Statement in VB.NET
body: <p>For a school assignment I need to name computer based on their MAC-Adress. I have a mySQL table with two columns Mac-Adress and Computername. I want to use the computer's mac adress via following code, which works.</p>
  
  <p>Declaration of the globals</p>
  
  <blockquote>
    <p>Public connStr As String = "Database=Mac;" &amp; _
                        "Data Source=localhost;" &amp; _
                        "User Id=root;Password="
        Public mac_adress As String</p>
  </blockquote>
  
  <p>Getting the Mac Adress</p>
  
  <blockquote>
    <p>Public Sub MacAdres()
            Dim nic As NetworkInterface = Nothing</p>
  
  <pre><code>    For Each nic In NetworkInterface.GetAllNetworkInterfaces
          mac_adress = nic.GetPhysicalAddress.ToString
      Next
  End Sub
  </code></pre>
  </blockquote>
  
  <p>However, when I want to create the WHERE statement, I get an error. I'm using the following code for the WHERE statement.</p>
  
  <blockquote>
  <pre><code>Public Sub retriveData()
      Try
          Dim query As String = "SELECT * FROM 'mactable' WHERE 'Mac-adres' = '" &amp; mac_adress &amp; "'"
          Dim connection As New MySqlConnection(connStr)
          Dim cmd As New MySqlCommand(query, connection)
  
          connection.Open()
  
          Dim reader As MySqlDataReader
          reader = cmd.ExecuteReader()
  
          While reader.Read()
              MessageBox.Show(reader.GetString(1))
          End While
  
          reader.Close()
          connection.Close()
      Catch ex As Exception
          Console.WriteLine(ex.Message)
      End Try
  End Sub
  </code></pre>
  </blockquote>
  
  <p>What am I doing wrong?</p>
  
  <blockquote>
    <p>A first chance exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in >MySql.Data.dll</p>
  </blockquote>