Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2006-07-13
3
Medium Priority
?
617 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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

886 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