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

x
?
Solved

vb.net datatable

Posted on 2006-10-30
4
Medium Priority
?
382 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
ID: 17837810
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
ID: 17837826
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 1000 total points
ID: 17838598
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
ID: 17842134
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

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 …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

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