Formatting Data in Dataset.

J

jayuya

Can anyone give a sample code, tip, or a web link with an
example of how to format data to currency. eg: $3451.25

I set a dataadapter and I fill the dataset from a SQL
Statement, but some fields are a double data type and I
need to display those fields to the user in currency
format...

I am using ASP.NET/VB.NET/ADO.NET

here is what i got so far...

Dim sql As String
Dim DB As New ADO_Net()

sql="select id, name, AmtOne,AmtTwo from myTable;"

'open database connection
DB.OpenConn()
' Load the dataset
DB.SetDataAdapter(sql, "myTable")

' Get the table from the dataset
Dim DataTable As DataTable = DB.DtSet.Tables(0)

Dim i As Integer
For i = 0 To DataTable.Rows.Count - 1

'need to format fields in currency
'before i display into the PDF document

'the DisplayReportRow function
'draws a string with all the columns
'into the pdf documents but
'I need to format some fields like Currency
Call DisplayReportRow(DataTable.Rows(i))

Next i

DB.DataAdapter.Dispose() 'close data set
DataTable.Dispose() 'close data table
DB.CloseConn() 'close database connection

'end of code

thanks,
jayuya
 
M

Matt

What i like to do is to format the data directly in your SQL statement
instead of in the the application. What kind of database are you
working with?

In SQL-Server you can use '$' + CONVERT(varchar, SomeMoneyValue, 3)

In Access there is a Format function to do this
 

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

Members online

No members online now.

Forum statistics

Threads
473,779
Messages
2,569,606
Members
45,239
Latest member
Alex Young

Latest Threads

Top