473,808 Members | 2,851 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to create a new column in a datatable from two existing column

I want to create a new column in a datatable from two existing columns. I
have no problem to create the new column using the datatable.colum ns.add
method. The problem is the value of the new column may become system.dbnull
since one of the two existing columns may have system.dbnull. How can I fix
it so the new column will get the value of the other column even the other
column is system.dbnull?

Sep 29 '07
13 2608
Hi Armin,

What I mean is the value of the new column will have the combined value of
existing columns I specified using datatable.colum ns.add().

"Armin Zingler" wrote:
"Peter" <Pe***@discussi ons.microsoft.c omschrieb
Hi Armin,

I add the new column based on existing columns. If one of the based
columns contains null (dbnull), the new column will contain null
regardless the value in other based columns.

What is a "column based on existing columns"?
Armin
Oct 2 '07 #11
The value of the new column will simply be the value of columnX + the value
of columnY. This is simply done by issuing datatable.colum ns.add().
However, the value of the new column will be null if either one of the
columns is null.

"Armin Zingler" wrote:
"Peter" <Pe***@discussi ons.microsoft.c omschrieb
Hi Armin,

What I mean is the value of the new column will have the combined
value of existing columns I specified using datatable.colum ns.add().

What's a "combined value"? Sorry for asking if that's too obvious.

"Armin Zingler" wrote:
"Peter" <Pe***@discussi ons.microsoft.c omschrieb
Hi Armin,

I add the new column based on existing columns. If one of the based
columns contains null (dbnull), the new column will contain null
regardless the value in other based columns.

What is a "column based on existing columns"?
Armin
Oct 2 '07 #12
"Peter" <Pe***@discussi ons.microsoft.c omschrieb
The value of the new column will simply be the value of columnX +
the value of columnY. This is simply done by issuing
datatable.colum ns.add(). However, the value of the new column will
be null if either one of the columns is null.
Ok, but how do you calculate the values in the column? The sum must be put
into the rows at any time.
"Armin Zingler" wrote:
"Peter" <Pe***@discussi ons.microsoft.c omschrieb
Hi Armin,
>
What I mean is the value of the new column will have the
combined value of existing columns I specified using
datatable.colum ns.add().
What's a "combined value"? Sorry for asking if that's too obvious.

"Armin Zingler" wrote:
>
"Peter" <Pe***@discussi ons.microsoft.c omschrieb
Hi Armin,
>
I add the new column based on existing columns. If one of
the based columns contains null (dbnull), the new column
will contain null regardless the value in other based
columns.

What is a "column based on existing columns"?


Armin
Oct 2 '07 #13
Peter,

What Armin probably asks is. Show that piece of code that you are using. It
seems that people is afraid to show that here, why we don't understand,
because really you are not showing secrets or your own inventions with that.

We are not forever asking direct questions here in this newsgroup, however I
know that Armin often asks, "Show us a piece of your code".

:-)

Cor

Oct 2 '07 #14

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

Similar topics

2
8567
by: Jacob | last post by:
A simple question: I've read a couple of things that indicates I can create a new table in my database using some SQL command. Is this correct? I would like to load a database into a DataSet, make changes to the existing DataTable(s), add NEW DataTable(s) if necessary and save the changes back to the database. I'm stuck on this problem. Any documentation on this would be great. Thanks,
4
2414
by: Bill Todd | last post by:
Is there any way to display the RowState of each row in a computed column in the DataTable? -- Bill
6
21481
by: Dan V. | last post by:
I would like to create a 2D string list (2D ArrayList ???). I would like to pass in a table or query as a parameter and have both columns transform into a 2D ArrayList. When I sort the one 'column' in the ArrayList, the other is automatically sorted and so I can use IndexOf without fear. This is because I will be going through 20,000 some odd records and don't want to use a Lookup type of table/query; I figure an ArrayList.IndexOf method...
3
14318
by: MrNobody | last post by:
I've read that the expression property for DataColumns is used to "Sets or retrieves the expresssion used to filter rows, calculate the values in a column, or create an aggregate column.". I have seen examples on how to filter a column, but how would I filter out an entire row depending on the value of a column? For example, if I wanted to filter out every row in a multi-column table where the "Is Fubar" column equals "true", how would...
1
1911
by: Prince | last post by:
Hi all, Can anyone tell me how to create auto generated values in a DataTable column? Looking forward for the reply.... Thanx in advance...
1
1505
by: jg | last post by:
I need to create a DataTable object, but I dont want to add columns programatically, the DataTable should have columns based on a Table in my SQL database. How can I create a DataTable with column structure based on a SQL database? Thanks
0
1090
by: BostonNole | last post by:
I am trying to find a way to create a new DataTable from an existing DataTable by selecting only certain columns and with a conditional. For example I want to do something like this: Dim myOriginalDataTable as DataTable Dm myNewDataTable as DataTable myNewDataTable = myOriginalDataTable(select column1, column3, column4 where column5 = 1)
4
2173
by: mojeza | last post by:
I would like to create generic object which will be used for store of single row of DataTable. Lets say I create class as follow: Public Class Participant Public ParticipantID As Int64 Public LastName As String Public FirstName As String End Class then I get a data from the database to DataTable and create array of
1
3385
by: TG | last post by:
Hi! I have an application in which I have some checkboxes and depending which ones are checked those columns will show in the datagridview from sql server or no. After that I have 2 buttons: 1) export to excel button exports the visible columns from the datagridview to excel (this works fine)
0
9721
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
10631
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
10374
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
9196
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
7651
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
6880
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
5548
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...
1
4331
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
3
3011
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.