Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2006-07-13
3
Medium Priority
?
611 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

730 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