Solved

vb.net datatable

Posted on 2006-10-30
4
364 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 500 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

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

Suggested Solutions

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 …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

920 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

16 Experts available now in Live!

Get 1:1 Help Now