Solved

create a dataset or maybe datatable on the fly vb.net

Posted on 2006-07-13
3
582 Views
Last Modified: 2006-11-18
I am trying to add content to a datagrid.

I was under the impression that the only way to do this is by adding data from a datatabel or dataset.

How do you create either from scratch, give column names, then fill with data.

I want it to look like this

"ID", "name", "phone number"
1, "jack", "555-5555"
2, "joe", "555-4444"

I think after I have that, I can add it to a datagrid.

Thanks
0
Comment
Question by:jackjohnson44
3 Comments
 
LVL 17

Accepted Solution

by:
ZeonFlash earned 500 total points
ID: 17103364
       Dim ds As New DataSet
        Dim dr As DataRow

        'Add a new table to the dataset
        ds.Tables.Add()

        'Create the columns in the data table
        ds.Tables(0).Columns.Add("ID")
        ds.Tables(0).Columns.Add("name")
        ds.Tables(0).Columns.Add("phone number")

        'Create a new row for the data table
        dr = ds.Tables(0).NewRow

        'Set the values for the row
        dr.Item("ID") = 1
        dr.Item("name") = "John Doe"
        dr.Item("phone number") = "555-5555"

        'Add the row to the table
        ds.Tables(0).Rows.Add(dr)

        'Repeat as necessary

        'Bind the dataset to the datagrid
        DataGrid1.DataSource = ds.Tables(0)
0
 
LVL 35

Expert Comment

by:YZlat
ID: 17103799
where will you be getting the values from?
0
 

Author Comment

by:jackjohnson44
ID: 17107930
I am going to create it on the fly as an internal place to store info for my app.
I was using recordsets in vb6.

If you want to format some members when you set the data source how do you do that,
since nothing looped, you can't look at every member?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now