473,385 Members | 1,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Formatting Data in Dataset.

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
Nov 17 '05 #1
3 8025
Hi jayuya,

Here is a simple to follow place :
http://www.4guysfromrolla.com/aspfaq....asp?FAQID=181

By the way, I am interested to know how you print in PDF? Is it possible to
give an idea so that I can compare?

Thanks,

"jayuya" <ja****@cox.net> wrote in message
news:6d****************************@phx.gbl...
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

Nov 17 '05 #2
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
On Fri, 1 Aug 2003 16:08:19 -0700, "jayuya" <ja****@cox.net> wrote:
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


Nov 17 '05 #3
abacnet

I am using a PDF tool from
http://www.o2sol.com/public/webui/home.shtml

It is great, you can create PDF fast for .net with a few
lines of code, but you have to pay for it....

jayuya
-----Original Message-----
Hi jayuya,

Here is a simple to follow place :
http://www.4guysfromrolla.com/aspfaqs/ShowFAQ.asp? FAQID=181
By the way, I am interested to know how you print in PDF? Is it possible togive an idea so that I can compare?

Thanks,

"jayuya" <ja****@cox.net> wrote in message
news:6d****************************@phx.gbl...
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

.

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Yama | last post by:
Hi, I am writing a windows form that will query the database. string query = "SELECT TOP 2 * FROM Northwind.dbo.Customers" ; DBQuery Q = new DBQuery() ; bool result =...
7
by: Matthew Wieder | last post by:
Hi - I have a datagrid that has a black header and the rows alternate white and gray. The problem is that until items are added to the grid, the grid appears as a large black rectangle, which is...
0
by: Alex | last post by:
I have a dataset bound datagrid. I added my own columns (autogenerate=false). However I can't figure out how to display a hyperlink string coming from the DB as a functioning hyperlink. What can...
4
by: hope | last post by:
Hi, How can I format a string field using Data Formatting Expression property in datagrid? For example: format last name from BROWN to Brown. Thanks
1
by: msmcg | last post by:
I need to format the data in some textboxes using the Binding method with custom Currency and ShortDate format and parse handlers. Here is the code that I am using. I call it on the form load...
5
by: Mike Fellows | last post by:
I have a dataset wich contains 3 columns i wish to format the 3rd column which contains a date field but it shows the date as dd/mm/yyyy 00:00:00 i need to remove the time part of the data (i...
0
by: Randall Arnold | last post by:
I have a Microsoft Access report (built on a SQL Server 2000 query) I have exported as xml/html. I include a stylesheet in the original export for formatting of the report. The schema is...
2
by: serge calderara | last post by:
Dear all, I have an ASP.NET 1.1 application which show data collected from an sql database inside a datagrid bind to a dataset which contains all data retrive. I need to display ki^nd of...
14
by: Scott M. | last post by:
Ok, this is driving me nuts... I am using VS.NET 2003 and trying to take an item out of a row in a loosely-typed dataset and place it in a label as a currency. As it is now, I am getting my...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.