title: Connecting datagrid view to database in vb.net
body: <p>Ok so im trying to display everything in my MYSQL database using a datagrid view.  but what i got is not working, can somebody help me with my code</p>
  
  <pre><code>    Public Sub dataview()
      DataGridView1.DataSource = ""
      Dim bindingSource1 As New BindingSource()
      Try
      Dim cmd As New MySqlCommand("SELECT * FROM upload", db_con)
  
      With Me.DataGridView1
          .AutoGenerateColumns = True
  
          bindingSource1.DataSource = cmd
          .DataSource = bindingSource1
  
          .AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders
          .BorderStyle = BorderStyle.Fixed3D
          .EditMode = DataGridViewEditMode.EditOnEnter
      End With
          DataGridView1.DataSource = bindingSource1
      Catch ex As Exception
          MessageBox.Show("something went wrong")
      End Try
  </code></pre>