How to identify money datatype in ASP.Net

G

Guest

In VB, to know the field type of a column stored in a recordset the command I
use is

If rsQuery.Fields(k).Type = adCurrency Then

How will I achieve the same in ASP.net. I could not find a currency data
type in asp.net and the type is idenfied as decimal.

I have two fields defined in Sql-Server, one is money and other is decimal.
In asp.net both are identified as decimal.

My requirement is, If the type is money I am adding a $ symbol as prefix and
if it is a decimal I just leave as it is. How to achieve this in asp.net
 
G

Guest

Thanks for your reply, However my doubt still exists.

I have pasted the sample code here. In thse lines of code, When I convert
the datatype to string, the currency data type gets converted to decimal, How
will I identify the currency datatype


If ds.Tables(0).Columns(k).DataType.ToString =
"System.DateTime" Then
sVal = Format(ds.Tables(0).Rows(j).Item(k),
"mm/dd/yy")
objExcel.Cells(RowCounter, ColCounter) = sVal
'* Be default the money datatype and numeric data type both are identified
as decimal
ElseIf ds.Tables(0).Columns(k).DataType.ToString =
"System.Decimal" Then
sVal = ds.Tables(0).Rows(j).Item(k)
objExcel.Cells(RowCounter, ColCounter) = sVal
objExcel.Range(objExcel.Cells(RowCounter,
ColCounter), objExcel.Cells(RowCounter, ColCounter)).Select()
'** I want to execute the below code only if the datatype is money and not
for decimal. How will I
'** incorporate the same.
objExcel.Selection.NumberFormat = "$#,##0.00"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top