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
248 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
1 Comment
 
LVL 22

Accepted Solution

by:
Snarf0001 earned 500 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now