View Single Post
  #1 (permalink)  
Old December 21st, 2006, 02:37 PM
rsm42 rsm42 is offline
Authorized User
Join Date: Sep 2006
Location: , , .
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
Default Display Decimal Places


Can someone assist with a query in 1.1, vb2003 using access databases. When I display my product list in a datagrid I want the sale price to be displayed e.g. 530.00. Instead the display is shown as 530.

Now the format of the saleprice in the database is set to currency with two decimal places. The only way it seems to display as if the value is other than zeroes at the end e.g. 530.99.

Here's some sample code - any ideas ? Also how about also adding in the pound sign as well i.e. £530.00?

<%@ Page Language="VB" %>
<script runat="server">

        Sub Page_Load
            DataGrid1.DataSource = ShowItems()
        End Sub
        Dim curSalePrice As Decimal

        Function ShowItems() As System.Data.IDataReader
            Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=F:\db\nwguitars.mdb"
            Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString )

            Dim queryString As String = "SELECT [tblProducts].[intProductID], [tblProducts].[strProductName], [tblProducts"& _
    "].[curSalePrice], [tblProducts].[intQuantityInStock] FROM [tblProducts]"
            Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
            dbCommand.CommandText = queryString
            dbCommand.Connection = dbConnection

            Dim dataReader As System.Data.IDataReader = dbCommand.ExecuteReader(System.Data.CommandBehavio r.CloseConnection)

            Return dataReader
        End Function

    <form runat="server">
        <asp:DataGrid id="DataGrid1" runat="server"></asp:DataGrid>