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

x
?
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
?
259 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
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…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

609 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