?
Solved

How can I use the type of a DataSet Table Column instead of converting it to a string first then back to a number?

Posted on 2014-03-06
1
Medium Priority
?
258 Views
Last Modified: 2014-03-07
I have a numeric column in a table in a dataset.  I want use that column data in an equation without pulling the value out into a local decimal.

decimal amount = decimal.Parse(segDS.Tables[0].Rows[0]["Annuity_Issued_Period"].ToString()) + decimal.Parse(lifeFitDS.Tables[0].Rows[0]["Annuity_Issued_Period"].ToString());

Open in new window


I'd prefer not to so do decimal.Parse on a ToString if I don't have to.
0
Comment
Question by:Bruce
[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
1 Comment
 
LVL 23

Accepted Solution

by:
Snarf0001 earned 2000 total points
ID: 39911081
sql numeric should map to a decimal, so all you should have to do is cast the value.

decimal amount = (decimal)segDS.Tables[0].Rows[0]["Annuity_Issued_Period"] + (decimal)lifeFitDS.Tables[0].Rows[0]["Annuity_Issued_Period"];

Open in new window


Note that this will fail if you're bringing back nulls though.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

762 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