Solved

vb.net datatable

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

786 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