title: How to Fill Data From Database to datagridview and combobox - vb.net
body: <p>I need to Fill data from database to my Datagrid and two Combobox.</p>
  
  <p>I have 3 tables, "Tipo", "Marca" and "Modelo".
  The table "Modelo" have two foreign key from "Tipo" and "Marca".</p>
  
  <p><img src="https://i.stack.imgur.com/2It4X.png" alt="Print"></p>
  
  <pre><code> Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
          CarregarDados()
      End Sub
  
      Private Sub CarregarDados()
          cn.ConnectionString = "server=localhost;user id=root;database=automoveldb"
          cn.Open()
          'Load DataGridView
          Try
              With Cmd
                  .CommandType = CommandType.Text
                  .CommandText = "SELECT modelo.id Id, marca.Nome NomeMarca, tipo.Nome NomeTipo, modelo.Nome NomeModelo FROM modelo INNER JOIN Marca ON marca.id = modelo.IdMarca JOIN tipo ON tipo.id = modelo.IdTipo;"
                  .Connection = cn
              End With
              MsgBox(Cmd.CommandText)
              With Da
                  .SelectCommand = Cmd
                  .Fill(dt)
                  dgvModelo.DataSource = dt
              End With
  
          Catch ex As Exception
              MsgBox(ex.Message)
          Finally
              cn.Close()
          End Try
  
          '*************************
          Try
              With Cmd
                  .CommandType = CommandType.Text
                  .CommandText = "SELECT * FROM Tipo;"
                  .Connection = cn
              End With
              MsgBox(Cmd.CommandText)
              With Da
                  .SelectCommand = Cmd
                  .Fill(dt)
                  cmbTipo.ValueMember = "Id"
                  cmbTipo.DisplayMember = "Nome"
                  cmbTipo.DataSource = dt
              End With
  
          Catch ex As Exception
              MsgBox(ex.Message)
          Finally
              cn.Close()
          End Try
      End Sub
  </code></pre>
  
  <p>MyDatabase</p>
  
  <p><img src="https://i.stack.imgur.com/p3s44.png" alt="enter image description here"></p>
  
  <p>Result my code</p>
  
  <p><img src="https://i.stack.imgur.com/ARH3q.png" alt="enter image description here"></p>
  
  <p>My combobox Type was filled but added in the datagridview a new column, i dont want it</p>