3
My problem is following, I make a query in the database that returns me a datatable with a wide variety of fields. The goal is to display this query in datagridview, however, displaying only some of the datatable fields.
I had a previous code here, but it just stopped working.
I will describe the process:
- 1º Performs Database Search and Returns Completed Datatable
2º Creates columns in datagridview and associates them to Datatable fields
With DgvErros .ColumnCount = 2 .AutoGenerateColumns = False .Columns(0).Name = "Codigo_Produto" .Columns(0).DataPropertyName = "Codigo_Produto" .Columns(1).Name = "Descricao" .Columns(1).DataPropertyName = "Descricao" .DataSource = Bs .AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells End With
In my consultation, I have the field "Product code"... but the program triggers an error when arriving at the part where it gives a name to Datagridview column 0.
Error : "Unable to set the Columncount property in a data-limited Datagridview control."