471,354 Members | 1,397 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

Why use the DataTableMapping in SqlDataAdapter when updating?

Hi,

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

Jason
Dec 12 '05 #1
2 8775
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 DataTableMappingCollection object. This
object contains a collection of DataTableMapping objects. Adding the
following line of code adds a DataTableMapping object to the TableMappings
collection to tell the DataAdapter that it should communicate with a
DataTable called Employees instead:

DataAdapter.TableMappings.Add("Table", "Employees")

Once you’ve created a DataTableMapping 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 DataTableMapping 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*******@yahoo.nospammin.com> glsD:46********************************* *@microsoft.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 DataTableMappingCollection object.
This
object contains a collection of DataTableMapping objects. Adding the
following line of code adds a DataTableMapping object to the TableMappings
collection to tell the DataAdapter that it should communicate with a
DataTable called Employees instead:

DataAdapter.TableMappings.Add("Table", "Employees")

Once youve created a DataTableMapping 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 DataTableMapping in SqlDataAdapter when
Updating
data.
Would someone give me some advice?
Thanks for help.

Jason

Dec 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by rkbnair | last post: by
1 post views Thread by Steven Blair | last post: by
1 post views Thread by trialproduct2004 | last post: by
reply views Thread by Analizer1 | last post: by
reply views Thread by DaveL | last post: by
18 posts views Thread by navyjax2 | last post: by
reply views Thread by XIAOLAOHU | last post: by

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.