473,480 Members | 3,098 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DataTable reference

I have created a DataSet (dsCurrent) and to it I have added 3
DataTables. Using the same DataTable variable (dtCurrent).
I am trying to get a reference to it by doing something like.
DataTable dt = dsCurrent.Tables("Table1");
but that obviously doesn't work.
How can I do this?

Thanks,

Apr 25 '06 #1
3 4542
Marty,
It "obviously" should work, provided you gave your DataTable the .TableName
"Table1" before you added it to your DataSet. Otherwise, you would need to
get it out by ordinal (e.g. MyDataSet.Tables[2] ).

Hope that helps.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Marty" wrote:
I have created a DataSet (dsCurrent) and to it I have added 3
DataTables. Using the same DataTable variable (dtCurrent).
I am trying to get a reference to it by doing something like.
DataTable dt = dsCurrent.Tables("Table1");
but that obviously doesn't work.
How can I do this?

Thanks,

Apr 25 '06 #2
Well no it didn't until I read your post!
I needed
dsCurrent.Tables["Table1"];
not
dsCurrent.Tables("Table1");

Doh!
It's the simple things in life...
Thanks a bunch

Apr 25 '06 #3
If you happen to be using the MS Data Application Block there is a
TableMappings property that lets you modify tablenames into something
more friendly. The whole "Table1" thing is ok if you only have 1 or 2
datatable.

- John Fullmer

Apr 25 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1737
by: Mountain Bikn' Guy | last post by:
When one gets a row from a database (ie, a DataTable), the row contains a typed value in each column. How is this typically implemented behind scenes. I want to build this functionality myself. The...
5
10001
by: Stefan Turalski \(stic\) | last post by:
Hi, I'm wondering if there is a way to send a method parametrs by ref when DataTabel is a type of this value ? I done some sort of select over DataTable columns, just by removing them froma...
3
9948
by: Mico | last post by:
I would be very grateful for any help with the following problem: I use a DataAdapter to fill a DataSet in the Page_Load method. Later, I use this DataSet to construct a DataTable, then create...
6
2224
by: Young J. Putt | last post by:
I've got a list box bound to a Datatable, like this: lstProjects.DataSource = m_oProjectSet.DataTable lstProjects.DisplayMember = "ProjectDesc" lstProjects.ValueMember = "ProjectID" I want to...
3
1704
by: Fred Nelson | last post by:
Hi: I have created a datatable and I'm able to access it by key values. I need to be able to go to the "top" of the datatable and process records sequentially until they are completed. I...
12
2259
by: Doug Bell | last post by:
Hi, I am having problems trying to create a (temporary) DataTable from a selection from a DataGrid (dgOrders). dtOrdDetails is declared as a Public DataTable Sub is: Dim stFilter as String...
0
1467
by: Shell | last post by:
As i am passing datatable from webservice to UI My Web Method is as follows :- Public Function GetData() As DataTable Dim objData As New MyClass Return objData.GetData() End Function In my...
4
4732
by: oopman2002 | last post by:
I have created a DataSet DataTable which is comprised of data from a number of sources. The resultant datatable is about 500,000 records and writing them out one at a time takes forever. Does...
8
11014
by: cj | last post by:
I have a program to display queries to a SQL db. I type my query in a textbox and click a button and the results display in a datagrid. I could use either dataset or datatable to read the data in...
9
6945
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
I've got a routine that builds a table using different queries, different SQL Tables, and adding custom fields. It takes a while to run (20 - 45 seconds) so I wrote a thread to handle the table...
0
7055
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7061
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7030
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5367
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4799
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4503
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3015
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3011
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.