Hi

I've design a datagridview with 6 columns. But i got a code somewhere in internet,the code make my datagridview added with 8 more columns from database. i dont know how to put the data from database into specific columns in the designed datagridview. on database, i have 8 columns, but i want to retrieve data from 3rd until the last row. database column name =id, agentname, customername, icnum, address, phonenum, dateform, emailcust.

can someone help me??

this is the code

Try
                mycn.Open()
                da = New OleDbDataAdapter("select*from custlist where agentnamecust= '" & Me.agentlist.Text & "' ", mycn)

                'create command builder
                Dim cb As OleDbCommandBuilder = New OleDbCommandBuilder(da)

                'fill dataset
                da.Fill(ds, "custlist")

                KryptonDataGridView1.DataSource = ds
                KryptonDataGridView1.DataMember = "custlist"

            Catch ex As OleDbException
                MsgBox(ex.ToString)
            Finally
                ' Close connection
                mycn.Close()
            End Try

Edited 5 Years Ago by zarifin99ska: n/a

No need to create column at run time.
change line number 3 to

da = New OleDbDataAdapter("select customername, icnum, address, phonenum, dateform, emailcust from custlist where agentnamecust= '" & Me.agentlist.Text & "' ", mycn)

I understand, if i use that,it will only call which column i want, but on the datagridview, the headertext will be the same on database. I forgot to mentioned, i have design the datagridview with HeaderText value i added manually. i just want to insert the data on existing columns.

please help.

Edited 5 Years Ago by zarifin99ska: n/a

KryptonDataGridView1.AutoGenerateColumns = False

add this line at line number 10 which is blank in your code.
It will help you

got it, i clear existing column, and put

KryptonDataGridView1.Columns(0).HeaderText = "Customer Name"
KryptonDataGridView1.Columns(1).HeaderText = ....

Edited 5 Years Ago by zarifin99ska: n/a

This question has already been answered. Start a new discussion instead.