fomatting sqldbtype.money to (9, 2) ??

cwfontan

Active member
Joined
Jan 9, 2009
Messages
35
Programming Experience
1-3
fomatting sqldbtype.money to (9, 2) ?? there is not built in format for dbtype?

how would I get max of 12 chars(including decimal) 9,2 ?

I know I can trim it etc.. just checking if anyone knows better?
 
i want to display it in that format. i am returning the output parameter from sql 2005 to vb.net when I recieve the decimal back. I lose the formatting that I put it in in SQL


VB.NET:
'my vb.net getting parameter
Dim parameter3 As New SqlParameter()
            parameter3.ParameterName = "@totchrgs"
            parameter3.SqlDbType = SqlDbType.Money
            parameter3.Direction = ParameterDirection.Output


VB.NET:
'my sql SProc
 ALTER proc [dbo].[sp_getlanxchrgs]
(
@sopnumbe nvarchar(21),
@bachnumb nvarchar(15),
@totchrgs Decimal(9,2) Output
)
as
SET NOCOUNT ON
begin

select @totchrgs = sum(a.unitprce)
from dbo.boa_sop_lines_vw  a,
     dbo.boa_sop_header_vw b
where a.sopnumbe = b.sopnumbe and
      a.sopnumbe = @sopnumbe  and
      b.bachnumb = @bachnumb
 
When you get a number from a database it's just a number. Numbers have no formatting. If you want to display a string representation of a number in VB then you need to specify the appropriate format string when converting the data. For a number with two decimal places the format string would be "f2" or "n2". You can find out more about numeric format strings in the MSDN Library.
 

Latest posts

Back
Top