Dynamcally populating a TreeView

Could someone tell me what's wrong with my code?

im trying to do what the title of the post says.....

However, on the line

Dim row As New Data.DataRow

I get the following error

'System.Data.DataRow.Protected Sub New(builder As System.Data.DataRowBuilder)' is not accessible in this context because it is 'Protected'.      

What's wrong? How do I declare a row??


Private Sub FillCustomers(ByVal parent As TreeNode)
        Dim conn As New SqlConnection("Data Source=DAODEVBOX;Initial Catalog=suds_prototype;User ID=sa;Password=***")
        Dim ds As New Data.DataSet()
        Dim da As New SqlDataAdapter("select * from Categories", conn)
        da.Fill(ds, "Category")
        Dim row As New Data.DataRow
        For Each row In ds.Tables("Category").Rows
            Dim node As TreeNode = New TreeNode()
            node.Text = row("companyname").ToString()
            node.Value = row("customerid").ToString()
            node.PopulateOnDemand = True
            node.SelectAction = TreeNodeSelectAction.SelectExpand
    End Sub

Open in new window

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.

dont use New in your Row-declaration,

Dim row as Data.DataRow

because you are getting the row instance in the loop, and declaring it with new needs parameters.

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
bdb12Author Commented:
arggh! ok great thank you....
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.