datagridview in visual basic 2005

I am developing with Visual Basic 2005.
I need to hide an "Id"column on my datagridview.  I have the following line of code:

Dim adapter As New OleDbDataAdapter("select * from Clients", conn).  There are several columns that I do not want to be shown but my main concern is the "ID" column.

How do I hide ID column from the datagridview.
thanks
LVL 1
systems_axAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jorge PaulinoIT Pro/DeveloperCommented:
Do you populate the datagridview on runtime or on design mode ?
0
systems_axAuthor Commented:
I populate it in runtime like this:

  Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Documents and Settings\Admin\Desktop\Test.mdb")
 Dim adapter As New OleDbDataAdapter("select * from Clients", conn)

        Dim dt As New DataTable("Clients")
        adapter.Fill(dt)
        dgvLastNames.DataSource = dt

I have a button that when pressed pulls all the columns from access.
0
Jorge PaulinoIT Pro/DeveloperCommented:
Ok, after you populate the datagridview you can do this:

Me.dgvLastNames.Columns(X).Visible = False

where X = Index or the column name
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Jorge PaulinoIT Pro/DeveloperCommented:
Also you can change the SQL statement without include the ID

Dim adapter As New OleDbDataAdapter("select field1,field2,field3,field4 from Clients", conn)
0
systems_axAuthor Commented:
thank you so much, it worked
0
Jorge PaulinoIT Pro/DeveloperCommented:
Glad I could help!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.