Connecting Tech Pros Worldwide Help | Site Map

How to identify money datatype in ASP.Net

Sri
Guest
 
Posts: n/a
#1: Nov 22 '05
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



Cor Ligthert
Guest
 
Posts: n/a
#2: Nov 22 '05

re: How to identify money datatype in ASP.Net


Sri,

You can use the overloaded version of ToString in combination with this

http://msdn.microsoft.com/library/de...classtopic.asp

I hope this helps,

Cor


Sri
Guest
 
Posts: n/a
#3: Nov 22 '05

re: How to identify money datatype in ASP.Net


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"

"Cor Ligthert" wrote:
[color=blue]
> Sri,
>
> You can use the overloaded version of ToString in combination with this
>
> http://msdn.microsoft.com/library/de...classtopic.asp
>
> I hope this helps,
>
> Cor
>
>
>[/color]
Cor Ligthert [MVP]
Guest
 
Posts: n/a
#4: Nov 22 '05

re: How to identify money datatype in ASP.Net


Sri,

I don't know the datatype money in Net. (That does not say that it does not
exist).

Not either as dbtype
http://msdn.microsoft.com/library/de...classtopic.asp

Or as system.type
http://msdn.microsoft.com/library/de...atypetopic.asp

That makes it in my opinion difficult to use that money type.

(Or is should be somewhere else)

Cor


Closed Thread