Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello
I have a small problem here, how to make in datagridview when form is loaded not to get from database the column names.
Because i have manually added column header names in datagridview options

Try
            With cmd
                .Connection = conn
                .CommandText = "Select * From Users"
                ds.Tables.Add(dt)
                Adapter.SelectCommand = cmd
                Dim cb = New OleDbCommandBuilder(Adapter)
                cb.QuotePrefix = "["
                cb.QuoteSuffix = "]"
                Adapter.Fill(dt)
                DataDisplay.DataSource = dt.DefaultView
                .Parameters.Clear()
            End With
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            Adapter.Dispose()
            dt.Dispose()
            ds.Dispose()
            cmd.Dispose()
            If conn IsNot Nothing Then
                conn.Close()
            End If
        End Try


and i have this problem here:
when it run my columns are doubled.

Please view Picture1 and Picture2 for more info
Picture 1[^]
Picture2[^]

How to solve this problem?

What I have tried:

If i remove headers names from datagridview options it works correct no double information loaded.
Posted
Updated 6-Jun-20 6:14am

1 solution

Don't add column names manually unless you are adding the data rows manually. If you use databinding the the BindingSource will be used to add the column headers.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900