473,414 Members | 1,563 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

How remove columns from ADO.NET DataTable?

I have an ADO.NET DataTable with several columns. I would like to remove
some columns. How can I do this. please?
Mar 25 '06 #1
3 35186
Actually, removing the columns is easy. It's that the when I assign one
datatable to another and then remove columns, it seems ot afect BOTH
datatables.

tblHistoryForChart = tblHistoryForGrid

tblHistoryForChart.Columns.Remove("Col1")

tblHistoryForChart.Columns.Remove("Col4")

tblHistoryForChart.Columns.Remove("Col6")

Thanks.

"Ronald S. Cook" <rc***@westinis.com> wrote in message
news:eo**************@TK2MSFTNGP12.phx.gbl...
I have an ADO.NET DataTable with several columns. I would like to remove
some columns. How can I do this. please?

Mar 26 '06 #2
Nevermind. tbl.Copy() was the way to go.

"Ronald S. Cook" <rc***@westinis.com> wrote in message
news:eY**************@TK2MSFTNGP09.phx.gbl...
Actually, removing the columns is easy. It's that the when I assign one
datatable to another and then remove columns, it seems ot afect BOTH
datatables.

tblHistoryForChart = tblHistoryForGrid

tblHistoryForChart.Columns.Remove("Col1")

tblHistoryForChart.Columns.Remove("Col4")

tblHistoryForChart.Columns.Remove("Col6")

Thanks.

"Ronald S. Cook" <rc***@westinis.com> wrote in message
news:eo**************@TK2MSFTNGP12.phx.gbl...
I have an ADO.NET DataTable with several columns. I would like to remove
some columns. How can I do this. please?


Mar 26 '06 #3
Don't forget that you're working with object references.
Your line tblHistoryForChart = tblHistoryForGrid means that both the
variables are pointing to the same memory location, so updating any
properties/ calling any methods on either will indeed affect both
variables

Mar 27 '06 #4

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

Similar topics

2
by: theWizK | last post by:
Hello all. I have noticed that when I generate a strongly-typed dataset from an xml schema that the DataTables that are generated have their constructors marked as internal. What this means is...
2
by: Kevin | last post by:
Hi Al Can someone tell me how to hide colums in a datagrid. I have a one datagrid that is a master and child and I would like to hide specific columns, how do I do this TI Kevin
5
by: jurson | last post by:
Hello, I remove row from DataTable. It works ok, the row is removed from collection. It should be marked as 'detached'. Am I right? Then I try to retrieve 'detached' rows using the code shown...
2
by: Dennis | last post by:
I have a class which inherits from DataGrid and it is bound to a a DataTable. I have defined the GridColumnStyles I want to display. Also, I have added an "InsertCol" to my class whidh has the...
3
by: C#_learner | last post by:
Hi!!, I have a table which i wanna print. what i wanted to do is, print the header and footer in every new page i am printing. The table which i am getting data is a dynamic table and with...
11
by: jschofield | last post by:
Hello all. Not sure if this is the correct place to ask this but I am new to php and I am building a script to remove certain columns in a comma delimited file plus other things. My problem is...
11
by: David C | last post by:
I have a Gridview that has 10 columns. I have a condition where I need to hide 5 of them but I'm not sure how to hide a column. I can hide a cell ok in the row databound event but not sur how to...
44
by: Smokey Grindle | last post by:
I have a list box on my form, but I need to databind it to a data table that is a private member of the form's class... so I basically have Public Class MyForm priate m_MyTable as new datatable...
1
by: Derek Hart | last post by:
What is the maximum number of columns a DataTable can have?
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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
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,...
0
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...

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.