TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Charlie
NA
7
9.3k
Data conversion and manipulation
Dec 25 2012 10:30 AM
Hia all,
Hoping you're all having a great festive season !!
Quick question to pose :-
I've a DataTable that has a single column and houses data in string format (as imported from external files). I'm now moving this data to a secondary DataTable and would like to apply some conversion / manipulation in the process.
I'd like to do the following :-
- Convert a column in DataTable2 to Decimal
- Read the string data from DataTable1, convert it to a decimal datatype, multiply the resulting value by 100 and apply the Absolute mathematical function.
- Insert the result into DataTable2
I can do each of the functions (multiplication, Absolute, etc.) independantly on static data (ie:- not dynamic data from a DataTable) and can copy data back & forth between the DataTables. The issue I have is doing all in a single step.
ie:-
foreach (DataRow row in DataTable1.Rows)
{
decimalVal = System.Convert.ToDecimal(row);
decimalVal = (decimalVal * 100);
abs = Math.Abs(decimalVal);
DataTable2.ImportRow(abs);
}
Naturally the above does not work but hopefully gives an idea as to what I'm attempting to do.
Any help / pointers would be really useful.
Thanks
Reply
Answers (
0
)
i am inserting the record in the database but it is not save
c# windows application