I have created a Datagridview with 4 Columns, EJ:
ID, Name, Quantity, other
But i want to fill these 3 Columns from MySQL EJ:
item_id, item_name, item_quantity
I tryed this code:
Using cn As New MySqlConnection("server=10.10.2.1;userid=root;password=gf-159753;database=quick_admon")
cn.Open()
Dim da As New MySqlDataAdapter("SELECT * from qa_items", cn)
' DataTable
Dim dt As New DataTable
' llenar el DataTable
da.Fill(dt)
' enlazar el DataTable al BindingSource
list_items.DataSource = dt
With list_items
.MultiSelect = False
.SelectionMode = DataGridViewSelectionMode.FullRowSelect
.DataSource = list_items.DataSource
End With
End Using
but this creates new columns and does not write to the existing, took a while looking for a solution but only find methods like this.
You failed to
bindthe columns from your query into your datagrid view columns. To do this,And you’re done!
UPDATE
Setting DataPropertyName Propgramatically
or Assuming that ID is your first column: