Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Datatable add int column to extisting table

Posted on 2008-06-20
4
Medium Priority
?
969 Views
Last Modified: 2012-05-05
I have got a datatable with several rows. I want to add a column of type int.
If I do following I get an error: 'dataType' argument cannot be null.
Parameter name: dataType

 ds.Tables[0].Columns.Add("NewId", System.Type.GetType("System.Int"));

After I have created the column I will loop through the rows in the table and fill values in the new column. How can I add this new int column?
0
Comment
Question by:johnkainn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 19

Accepted Solution

by:
LordOfPorts earned 320 total points
ID: 21833320
Try System.Int32 instead of System.Int, i.e.:

ds.Tables[0].Columns.Add("NewId", System.Type.GetType("System.Int32"));
0
 
LVL 11

Assisted Solution

by:Mihai Stancescu
Mihai Stancescu earned 180 total points
ID: 21833340
You can try this:

ds.Tables[0].Columns.Add("NewId", typeof(int));
ds.Tables[0].AcceptChanges;


Hope this helps!

Regards,
Mishu
0
 

Expert Comment

by:icenhance
ID: 25445374
thanks
0
 
LVL 11

Expert Comment

by:Mihai Stancescu
ID: 25446338
Your welcome !
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question