473,728 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why use the DataTableMappin g in SqlDataAdapter when updating?

Hi,

I am wondering why use the DataTableMappin g in SqlDataAdapter when Updating
data.
Would someone give me some advice?
Thanks for help.

Jason
Dec 12 '05 #1
2 8920
The TableMappings collection controls how the DataAdapter maps your DataSet
to your database. If you leave a DataAdapter object’s TableMappings
collection empty, call the Fill method, and supply a DataSet as a parameter
without specifying a table name, the DataAdapter will assume that you want to
work with a DataTable called Table.

The TableMappings property returns a DataTableMappin gCollection object. This
object contains a collection of DataTableMappin g objects. Adding the
following line of code adds a DataTableMappin g object to the TableMappings
collection to tell the DataAdapter that it should communicate with a
DataTable called Employees instead:

DataAdapter.Tab leMappings.Add( "Table", "Employees" )

Once you’ve created a DataTableMappin g object, you can create column
mappings for the table.

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


"Jason Huang" wrote:
Hi,

I am wondering why use the DataTableMappin g in SqlDataAdapter when Updating
data.
Would someone give me some advice?
Thanks for help.

Jason

Dec 12 '05 #2
Thanks Peter.
But I am wondering why we need to use the TableMapping and ColumnMapping, it
seems taht we can do table manipulation without the Mappings.
Jason


"Peter Bromberg [C# MVP]" <pb*******@yaho o.nospammin.com > glsD: 46************* *************** ******@microsof t.com...
The TableMappings collection controls how the DataAdapter maps your
DataSet
to your database. If you leave a DataAdapter objects TableMappings
collection empty, call the Fill method, and supply a DataSet as a
parameter
without specifying a table name, the DataAdapter will assume that you want
to
work with a DataTable called Table.

The TableMappings property returns a DataTableMappin gCollection object.
This
object contains a collection of DataTableMappin g objects. Adding the
following line of code adds a DataTableMappin g object to the TableMappings
collection to tell the DataAdapter that it should communicate with a
DataTable called Employees instead:

DataAdapter.Tab leMappings.Add( "Table", "Employees" )

Once youve created a DataTableMappin g object, you can create column
mappings for the table.

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


"Jason Huang" wrote:
Hi,

I am wondering why use the DataTableMappin g in SqlDataAdapter when
Updating
data.
Would someone give me some advice?
Thanks for help.

Jason

Dec 13 '05 #3

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

Similar topics

2
399
by: rkbnair | last post by:
-------------------------------------------------------------------------------- I have a problem in updating certain data in an SQL table. Hope, I have the right syntax. It accepts the commands. However, the data is never updated. Placed below is the code. Thanks.
1
2105
by: Steven Blair | last post by:
Hi, Here is a short decsription of my problem. I have written a dll for Database accessing. I have one method which can return a Dataset and another method which takes a Dataset and upates a Database. (Disconnected Datasets). The problem I have is a new SqlAdapter is required before updating the Database: Therefore, to allow the update I have to do the following:
3
4360
by: Fernando | last post by:
I am having problems with updating the changes done over a DataSet to a Database. All the changes being done using the Form are stored in the Dataset, but when i decide to close the Form and open the form again, the changes are lost. Also, the modification process works great, but adding or deleting a row doesn't work. I am using a SQLDataAdapter to manage all the insert/delete/modification/select over the table. I supose the problem is...
6
2444
by: Jerry Higgins | last post by:
I added a SqlDataAdapter to a web form, created a data connection, and generated a dataset. I then connected it to a DataGrid control. When I do this using the SqlServer database on my machine everything works fine. When I do it using a SqlServer database on another machine I get the "Login failed for user sa" error. However, when I right click on the SqlDataAdapter and click "Preview Data" it brings back the data OK. Why would it...
1
1154
by: trialproduct2004 | last post by:
hi all i am having problem at a time of using sqldataadapter. My adapter is using two tables into which i want to add records. I am using two dataset for updating these table. My problem is even if i added records into two different tables it is adding same record twice in one table only and not in second table.
1
8072
by: languy | last post by:
Hi there I'm having a problem when using the SqlDataAdapter. When calling the Update(DataSet, string) method I get the following error message "String or binary data would be truncated". The rows neither have data that exceeds 8000 chars nor contain any LOB fields. Furthermore the data is transferred between two tables that are bitwise identical. -- snip -- System.Data.SqlClient.SqlCommand command =
0
882
by: Analizer1 | last post by:
How Can i set SqlData Adapter to update like a Batch Update for instance: I have 10,000 rows that have changed when i call SqlDataAdapter.Update(table) it seems like its updating 1 row at a time Tks
0
252
by: DaveL | last post by:
c# 2.0, etc, sql server 2005 i have a situation where i will be joing 3 tables in a proc to return a row set of data to be verified by a windows service. example: Select m.TransactionId, m.Statusid,m.Field1,m.Field2,c1.field1,c2.field2 from myMaster m (nolock) join child1 c1 (nolock) on c1.rowid = m.rowid join child2 c2 (nolock) on c2.rowid =c1.rowid
18
3943
by: navyjax2 | last post by:
What if your event handler has to be nonstatic?
0
8894
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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9265
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9122
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6704
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
6012
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
4522
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4787
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3230
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
2643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.