473,785 Members | 2,879 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

adding columns to an already-filled datatable?

VMI
In my Win app, I call a method that returns a datatable with all its columns
and is filled with data. After the table's returned, I need to add another
column to the datatable that will include data from an ascii file. For
example, the table may contain two columns: "emplcode" and "HrsWorked" . Once
I receive this table with all the data, I need to add another column to the
datatable ("Name"), go through every row in the datatable and find the
"emplcode" in the ascii file. Once I've found it, I'll copy the data, in the
file, to the datacolumn.

Is that possible?
Nov 16 '05 #1
1 2523
VMI,

Yes, it absolutely should be. All you have to do is create a new
DataColumn and add it to the DataTable in question using the Add method on
the DataColumnColle ction returned by the Columns property.

Then, you can cycle through the columns normally, and then add the data.
You might want to call AcceptChanges when you are done, depending on whether
or not you want the edits to be visible (when you set the column values,
each row will have an edit associated with it).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"VMI" <vo******@yahoo .com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
In my Win app, I call a method that returns a datatable with all its
columns
and is filled with data. After the table's returned, I need to add another
column to the datatable that will include data from an ascii file. For
example, the table may contain two columns: "emplcode" and "HrsWorked" .
Once
I receive this table with all the data, I need to add another column to
the
datatable ("Name"), go through every row in the datatable and find the
"emplcode" in the ascii file. Once I've found it, I'll copy the data, in
the
file, to the datacolumn.

Is that possible?

Nov 16 '05 #2

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

Similar topics

3
1814
by: Funnyweb | last post by:
When adding a field to a table using ALTER TABLE is it possible to check if the field already exits before the ADD command is run? If so how do I do this? Thanks Hamilton
5
2793
by: Paul | last post by:
Hi I have a table that currently has 466 columns and about 700,000 records. Adding a new DEFAULT column to this table takes a long time. It it a lot faster to recreate the table with the new columns and then copy all of the data across. As far as I am aware when you add a DEFAULT column the following happens:
11
14414
by: Bobbak | last post by:
Hello All, I have these tables (lets call it ‘EmpCalls', ‘EmpOrders', and ‘Stats') that each contain the list of EmployeeIDs, I want to be able to create a Module in which I could call in my VB form (by clicking and command button)that will add a column (field) to each table and label it with the current date that is specified in my form. Does anyone know how I can go about doing this? Any suggestion will be greatly appreciated.
3
4910
by: Raj | last post by:
Hi, I am trying to add some more information to the table which already has a lot a data (like 2-3000 records). The new information may be adding 2-3 new columns worth. Now my questions are: (1)Is it a good idea to add new columns to the existing table? then it will create these new columns for all old records, will it not result in wasting a lot of space?? (2)Is it a good idea to create a new table with the new information and have as a...
4
5089
by: Tim Donaldson | last post by:
I have a table generated by a query, and I'd like to add two new field columns to the end or to generate a query which has the same effect. One field is to be called "company" and has the word "pepsi" running down all the rows of the column. The 2nd field is to be called "person" and has the word "A.B." running down all the rows of the columns. How could I do this? Thanks. Tim Donaldson
3
4885
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that the best method? Do you have a sample of how to do this?
6
1496
by: Bart Schelkens | last post by:
Hi, I have another question. On my asp-page I put a label. I manually create a table and set that table in the text of the label. This way my table is displayed. My question is how can i add 2 columns that contain buttons to that table. The last two columns of my table need to contain buttons to edit or delete a
0
946
by: jy836 | last post by:
Hey all. I've created a DataGrid and bound it to a dataset, but I need to add several columns. The columns that I need to add have to be in the middle of the ones that are already there (as opposed to being appended after the last orginal column). These new columns will not be bound to the dataset. If possible, I'd appreciate it if someone could also give me an explanation of how to add a non-bound row below all original rows, which I will...
12
6223
by: JMO | last post by:
I can import a csv file with no problem. I can also add columns to the datagrid upon import. I want to be able to start importing at the 3rd row. This will pick up the headers necessary for the datagrid. Once I can get to that point I need some way to be able to add new data only to the new columns that were added. Here is some of my code: //Function For Importing Data From CSV File public DataSet ConnectCSV(string filetable)
1
6496
by: Normann | last post by:
I am trying to add data to an existing gridview, the gridview already has defined columns and I need to add data to these columns. However when I use gridview.datasource, it just adds new columns to the gridview. It is properly not that hard to do this, but I have been hammering my head on this problem for the last three days and I haven’t been able to find any help on Google. I have added the code I have already made and it works ok, it...
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10329
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
10152
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...
1
10092
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
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...
0
8974
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...
0
6740
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();...
1
4053
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
3650
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.