Solved

vb.net datatable

Posted on 2006-10-30
4
369 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
[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
  • 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

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…
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 …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

623 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