473,756 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing DataAdapater tablename property

I'm filling a dataset with the return of a stored procedure. The dataset
contains a number of tables which I am naming within the stored procedure,
however when I try to access the tables using the names assigned I get
errors. It doesn't seem to be assigning the names correctly within the stored
procedure - instead it uses default names: Table, Table1 etc.

e.g. Accessing using aDataSet.Tables["some tablename"]

Nov 16 '05 #1
2 1584
Use the TableMappings.A dd() method of the DataAdapter, like this:

sqlDA.TableMapp ings.Add("Table ", "MyFirstTableNa me");
sqlDA.TableMapp ings.Add("Table 1", "MySecondTableN ame");
sqlDA.TableMapp ings.Add("Table 2", "MyThirdTableNa me");

Then you can access the tables like:

dataSet.Tables["MySecondTableN ame"]

You can read more about it at
http://msdn.microsoft.com/library/de...mnmappings.asp.

You might also want to consider a strongly-typed DataSet.

HTH

DalePres
MCAD, MCDBA, MCSE


"KimD" <Ki**@discussio ns.microsoft.co m> wrote in message
news:F6******** *************** ***********@mic rosoft.com...
I'm filling a dataset with the return of a stored procedure. The dataset
contains a number of tables which I am naming within the stored procedure,
however when I try to access the tables using the names assigned I get
errors. It doesn't seem to be assigning the names correctly within the
stored
procedure - instead it uses default names: Table, Table1 etc.

e.g. Accessing using aDataSet.Tables["some tablename"]

Nov 16 '05 #2
I think this approach works when you know the order and number of tables
being returned from the stored procedure. However in my case I do not know at
the point of calling the SP how many tables will be returned.

"DalePres" wrote:
Use the TableMappings.A dd() method of the DataAdapter, like this:

sqlDA.TableMapp ings.Add("Table ", "MyFirstTableNa me");
sqlDA.TableMapp ings.Add("Table 1", "MySecondTableN ame");
sqlDA.TableMapp ings.Add("Table 2", "MyThirdTableNa me");

Then you can access the tables like:

dataSet.Tables["MySecondTableN ame"]

You can read more about it at
http://msdn.microsoft.com/library/de...mnmappings.asp.

You might also want to consider a strongly-typed DataSet.

HTH

DalePres
MCAD, MCDBA, MCSE


"KimD" <Ki**@discussio ns.microsoft.co m> wrote in message
news:F6******** *************** ***********@mic rosoft.com...
I'm filling a dataset with the return of a stored procedure. The dataset
contains a number of tables which I am naming within the stored procedure,
however when I try to access the tables using the names assigned I get
errors. It doesn't seem to be assigning the names correctly within the
stored
procedure - instead it uses default names: Table, Table1 etc.

e.g. Accessing using aDataSet.Tables["some tablename"]


Nov 16 '05 #3

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

Similar topics

2
2257
by: George Grodentzik | last post by:
I created a typed dataset from which I am trying to access the data. When I use the following code to access a row string name =dataset.person.firstName I receive an error System.IndexOutOfRangeException as if there are no rows. Yet when I dump the data to a file I receive (sample of file) <?xml version="1.0" standalone="yes"?><Dataset1 xmlns="http://tempuri.org/Dataset1.xsd"><Table><accountNo>1</accountNo><firstName>John ...
4
1781
by: stjulian | last post by:
I have a stored procedure that is supposed to 1. Increment a counter in Table A via a transaction 2. Use this value as the primary key to add in an address to customers Table B (Referenced as a "DECLARE @CustomerID INT" just after the AS clause) 3. Return the primary key. This works perfectly when being called from Query Analyzer supplying values in an EXEC line, however, accessing it from .ASP (IIS 5.0 on Win2K), the
3
1651
by: Christopher Weaver | last post by:
A component that I'm using expects the tables within it to be accessed as properties (DataSetName.TableName). I have created a DataSet like this: dsTaskActivities = new DataSet(); odbcDA_TaskActivities.FillSchema(dsTaskActivities, SchemaType.Source, "Tasks"); My DataAdabpter contains the necessary SQL to retrieve the table, "Tasks", and the new table ends up in the Tables property of the DataSet but not as an individual property of...
6
1229
by: DKode | last post by:
Ok, kind of a silly question I just want to know what the proper method is, When I have local Properties, ie: private bool _someVal; public bool SomeVal { get { return _someVal; } }
0
1357
by: Michael SL | last post by:
I am trying to get the Table Column definitions from a Microsoft Access 2000 database (*.mdb). Using VB with System.Windows.Forms.Form I do the following Dim OpenDBDialog As New OpenFileDialo OpenDBDialog.Filter = "Database files (*.mdb)|*.mdb OpenDBDialog.RestoreDirectory = Tru If OpenDBDialog.ShowDialog() = DialogResult.OK The Dim ColumnName As Strin Dim ii As Intege Dim jj As Intege Dim oConn As OleDbConnectio
6
13997
by: Andy Barber | last post by:
Hi, I'm trying to write an app that reads data from a table into a string variable for later use in my program. Below is a snippet of the code I'm using, which compiles ok, but at runtime I get and error 'Object reference not set to an instance of an object.' as soon as I try to access the data in the fields, I.e. at the line that reads 'KeyFlags(i) = rstFields("keyflag").value'
4
1422
by: John | last post by:
I am having a problem accessing the members in a structure via an interface and Class. ***Development Code*** Structure Person Public Name as String End Structure Interface IData Public Property Employee As Person
1
4561
by: technocraze | last post by:
Hi guys, I am having trouble resolving this error. Below mentioned is my code and implmentation. MS Acess is my front end and sql server is my backend. What i want to achieve is to be able to insert StudentId in the table matching the values chosen in the combo boxes and listboxes. This sound more like searching the table to insert StudentId matching the criterias. I have set the necessary configuration for ODBC connection (File...
1
1506
by: nsphelt | last post by:
I am wondering if it is possible to access the underlying property of a base class within a derived that has overridden that property. I am using VB.NET and when I use the MyBase keyword to access the property of the base class, it accesses the overridden property instead. Specifically, my class is inheriting the TextBox class and I am overriding the Text property to have it display something different based on the state of my class. I was...
0
9455
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10031
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8709
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7242
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5302
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3805
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 we have to send another system
2
3354
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2665
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.