Solved

vb.net datatable

Posted on 2006-10-30
4
360 Views
Last Modified: 2010-04-23
I have a problem with a datatable.

I want to pick the table by name, but it will not work, I can do it with an index though.

getDataSet returns a dataset

        myDataSet = myDB.getDataSet("select * from results")
        myDataTable = myDataSet.Tables(0)  'This does work

        myDataSet = myDB.getDataSet("select * from results")
        myDataTable = myDataSet.Tables("results")   'This does not work
0
Comment
Question by:jackjohnson44
  • 2
  • 2
4 Comments
 
LVL 17

Expert Comment

by:ZeonFlash
Comment Utility
You have to specifically assign the name of a datatable before you can reference it by name:

myDataSet = myDB.getDataSet("select * from results")
myDataSet.Tables(0).TableName = "results"
myDataTable = myDataSet.Tables("results")
0
 

Author Comment

by:jackjohnson44
Comment Utility
thanks, how would there ever be a table without the index 0?

how could I get 2 tables in the dataset?
So 0 would be the results table and 1 would be some other table?
0
 
LVL 17

Accepted Solution

by:
ZeonFlash earned 500 total points
Comment Utility
To get 2 DataTables, you'd need 2 SELECT statements, e.g.:  "select * from results select * from other_table".  That would give you the "results" tables as myDataSet.Tables(0), and the "other_table" as myDataSet.Tables(1).  
0
 

Author Comment

by:jackjohnson44
Comment Utility
thanks a lot, one more quick one

is there a way to not use an index?
I feel like there could be a possibility that it could change sometime.
Is there a way to call the table by its name?
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

771 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

10 Experts available now in Live!

Get 1:1 Help Now