Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Replace comma to dot when SQL is loaded.

Posted on 2002-03-15
2
Medium Priority
?
1,753 Views
Last Modified: 2010-08-05
Hi Experts.

I use aspgrid from www.aspgrid.com
Object reference below:
http://www.aspgrid.com/objectreference.html

I will post the code below my explanation.

I have problems with commas and dots.
When I store a value using a dot in a field
in the aspgrid and then save the record is
turned into a comma.

Example:

12.1 become 12,1

The datatype for the table field is float.

The real proble is if I click on the edit button
and want to change a value in a record I must
cahnge all commas to dots again.

If I should ignore my validation code and store the value
in the form as 12,1 it turns to 121
Therefore I must use a dot before my decimals.

So the solution must be to display replace the commas to dots when pressing on the edit button.

I have tried several solutions but none fo them works.

Really need some expert help here.

THANKS IN ADVANCE.






----------------------------------------------
<HTML>
<HEAD>
<TITLE>AspGrid 3.0 Demo - Expense Report</TITLE>


<SCRIPT LANGUAGE="JavaScript">
function Validate()
{
      
      if( isNaN(document.AspGridFormSave1.FIELD5.value ) )
      {
            alert('Not a number.');
            document.AspGridFormSave1.FIELD5.focus();            
            return false;
      
      }
      if( isNaN(document.AspGridFormSave1.FIELD6.value ) )
      {
            alert('Not a number.');
            document.AspGridFormSave1.FIELD6.focus();
            return false;
      }
      if( isNaN(document.AspGridFormSave1.FIELD7.value ) )
      {
            alert('Not a number.');
            document.AspGridFormSave1.FIELD7.focus();
            return false;
      }
      if( isNaN(document.AspGridFormSave1.FIELD8.value ) )
      {
            alert('Not a number.');
            document.AspGridFormSave1.FIELD8.focus();
            return false;
      }
      
      if( document.AspGridFormSave1.FIELD5.value == "")
      {
            alert('Field is empty.');
            document.AspGridFormSave1.FIELD5.focus();
            return false;
      }
      if( document.AspGridFormSave1.FIELD6.value == "")
      {
            alert('Field is empty.');
            document.AspGridFormSave1.FIELD6.focus();
            return false;
      }
      if( document.AspGridFormSave1.FIELD7.value == "")
      {
            alert('Field is empty.');
            document.AspGridFormSave1.FIELD7.focus();
            return false;
      }
      if( document.AspGridFormSave1.FIELD8.value == "")
      {
            alert('Field is empty.');
            document.AspGridFormSave1.FIELD8.focus();
            return false;
      }
            
      
      return true;
}
</SCRIPT>


<body bgcolor="#FFFFFF">
<p><b>Op-register v0.0.1</b><br>
  <%
            
      ' Create an instance of AspGrid
      Set Grid = Server.CreateObject("Persits.Grid")
            
      ' Specify location of button images
      Grid.Imagepath = "aspgrid/images/"
   
      ' Specify SQL statement. We store session IDs to allow simultaneos users to run the demo transparently
      Grid.SQL = "select id, sessionid, Productid, OpLocationid, InternalTime, InternalYield, CustomerTime, CustomerYield, EditedDate from OpRegister WHERE Productid= '"&Cstr(session("sessProductid"))&"' ORDER BY id"

      ' Connect using a DSNless connection string
      ConnectStr = "Provider=SQLOLEDB;Server=madeleine;Database=Operationsregister;UID=sa;PWD="
      Grid.Connect ConnectStr, "", ""
      
      ' Optional: specify a client-side JavaScript validation routine
      Grid.FormOnSubmit = "return Validate();"

      ' Use POST rather than GET
      Grid.MethodGet = False
          
      ' specify <TABLE> attributes of the grid
      Grid.Table.CellSpacing = 0
      Grid.Table.CellPadding = 0
      Grid.Table.Width = 600

      ' Hide the ID and SESSIONID columns
      Grid.ColRange(1, 3).Hidden = True

      ' specify the default value for the hidden SESSIONID column
      Grid.Cols("sessionid").DefaultValue = Session.SessionID
          
      Grid.Cols("Productid").DefaultValue = Cstr(session("sessProductid"))
      
      Response.write "Product:<font color=""red""><b>" & Cstr(session("sessProductid")) & "</b></font><br>"
      
      ' Enable control buttons at both sides of grid
      Grid.ShowLeftSideButtons

      ' Set header captions      
      Grid("OpLocationid").Caption = "Location"
      Grid("InternalTime").Caption = "Tid1"
      Grid("InternalYield").Caption = "Yield1"
      Grid("CustomerTime").Caption = "Tid2"
      Grid("CustomerYield").Caption = "Yield2"
      Grid("EditedDate").Caption = "Date"

      ' Set column width
      Grid.Cols(0).Header.Width = 35
      Grid.Cols(0).Cell.Width = 35
      Grid.Cols(0).Cell.NoWrap = True

      ' Columns 1, 2 and 3 (id, sessionid and Productid) are hidden
      
      Grid.Cols(4).Cell.Width = 10
      Grid.Cols(4).Header.Width = 10

      Grid.Cols(5).Cell.Width = 8
      Grid.Cols(5).Header.Width = 8

      Grid.Cols(6).Cell.Width = 10
      Grid.Cols(6).Header.Width = 10

      Grid.Cols(7).Cell.Width = 8
      Grid.Cols(7).Header.Width = 8
      
      Grid.Cols(8).Cell.Width = 10
      Grid.Cols(8).Header.Width = 10
      
      Grid.Cols(9).Cell.Width = 50
      Grid.Cols(9).Header.Width = 50      
      
      
      Grid.Cols(999).Cell.Width = 35
      Grid.Cols(999).Header.Width = 35
      Grid.Cols(999).Cell.NoWrap = True
      
      ' Set fonts, colors for the control columns
      Grid.Cols(0).Header.BgColor = "#90F0FE"
      Grid.Cols(0).Cell.Align = "CENTER"
      Grid.Cols(0).Cell.BgColor = "#FFFFFF"
      Grid.Cols(0).Cell.AltBgColor = "#E0E0E0"
      Grid.Cols(0).Footer.Align = "CENTER"
      Grid.Cols(999).Header.BgColor = "#90F0FE"
      Grid.Cols(999).Cell.Align = "CENTER"      
      Grid.Cols(999).Cell.BgColor = "#FFFFFF"
      Grid.Cols(999).Cell.AltBgColor = "#E0E0E0"      
      Grid.Cols(999).Footer.Align = "CENTER"

      ' Set fonts, colors and sizes for the data columns
      Grid.ColRange(2, 9).Header.Font.Face = "Arial"
      Grid.ColRange(2, 9).Header.Font.Size = 2
      Grid.ColRange(2, 9).Header.BgColor = "#A6CAF0"
      Grid.ColRange(2, 9).Header.NoWrap = True
      Grid.ColRange(2, 9).Cell.Font.Face = "Arial"
      Grid.ColRange(2, 9).Cell.Font.Size = 2
      Grid.ColRange(2, 9).Cell.BgColor = "#FFFFFF"
      Grid.ColRange(2, 9).Cell.AltBgColor = "#E0E0E0"

      ' Grid.Cols(<index>) is equivalent to Grid(<index>) as Cols is the default property
      
      ' Set the SIZE attribute for <INPUT TYPE=TEXT>      '
      Grid("OpLocationid").InputSize = 6
      Grid("InternalTime").InputSize = 6
      Grid("InternalYield").InputSize = 6
    Grid("CustomerTime").InputSize = 6
    Grid("CustomerYield").InputSize = 6
    Grid("EditedDate").InputSize = 10

      ' Display Category field as a drop-down list
      Grid("OpLocationid").AttachForeignTable "select OpLocationId, OpLocationName from OpLocation Where QuerySelection='"&Cstr(session("sessScheme"))&"' ", 1, 2
      
      ' Format the Date column      
    Grid("EditedDate").FormatDate "%d %b %Y", "%d %b %Y"
      Grid("EditedDate").DefaultValue = Date
      Grid("EditedDate").AttachCalendar
      Grid("EditedDate").Cell.NoWrap = True
      
      ' Enable sorting on all visible fields
      Grid.ColRange(2, 9).CanSort = True

      ' Enable client-side confirmation on record deletion
      Grid.DeleteButtonOnClick = "Are you sure you want to delete this record? (This message is cusomizable)"

      Grid.FormOnSubmit = "return Validate();"

      ' Peform server-side validation of date
      If Request("AspGridSave1.x") <> "" Then ' Adding or saving in progress
            If Not IsDate(Request("FIELD9")) Then
                  Response.Write "<B><FONT SIZE=2 FACE=Arial COLOR=#FF0000>Server-side validation: this is not a date!</FONT></B><P>"
                  Grid.IgnoreCommands ' do not save!
            Else ' verify date range
                  TheDate = CDate(Request("FIELD9"))
                  If TheDate < CDate("1/1/1995") Then
                        Response.Write "<B><FONT SIZE=2 FACE=Arial COLOR=#FF0000>Server-side validation: A date must be after 1/1/1995!</FONT></B><P>"
                        Grid.IgnoreCommands ' do not save!
                  End If
            End If
      End If
      
            Grid.Display

      ' Display a total by requerying the same recordset
      Response.Write "<P>"
      Set Rec = grid.Recordset
      Rec.Requery
      InternalTime = 0
      InternalYield = 0
      CustomerTime=0
      CustomerYield=0
      
      while Not Rec.EOF
            InternalTime = InternalTime + Rec("InternalTime")
            InternalYield = InternalYield + Rec("InternalYield")
            CustomerTime = CustomerTime + Rec("CustomerTime")
            CustomerYield = CustomerYield + Rec("CustomerYield")
            Rec.MoveNext
      wend

      Response.Write "<FONT SIZE=3><B>Internal time: " & InternalTime & "</B></FONT><br>"
    Response.Write "<FONT SIZE=3><B>Internal yield: " & InternalYield & "</B></FONT><br>"
    Response.Write "<FONT SIZE=3><B>Customer time: " & CustomerTime & "</B></FONT><br>"
    Response.Write "<FONT SIZE=3><B>Customer yield: " & CustomerYield & "</B></FONT>"
      
      Set Grid = Nothing

%>
</p>
</BODY>
</HTML>

0
Comment
Question by:superabbe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Expert Comment

by:ckaneta
ID: 6868212
sounds to me like a regional settings issue.....

but here's some code to change commas into dots

strVar = Replace(strVar,",",".")

so it'd probably be something like this

strVar = RSobj(FieldName)
strVar = Replace(strVar,",",".")
Response.Write strVar

0
 
LVL 1

Accepted Solution

by:
iwebdev earned 1000 total points
ID: 6898616
Column Object Method:

If you enter a number greater than 12.1 like 123456789 does it look like 1.234.567,89 ?

See FloatingPoint Method below.

Sub FormatNumeric(Decimal As Integer, Optional ThouComma = True, Optional NegativeSign = True, Optional FloatingPoint = True, Optional Prefix = "" )

Specifies numeric formatting for a column.
Decimal specifies the number of decimal positions for a number.
ThouComma is optional and True by default. If set to False, suppresses comma separators between 000's.
NegativeSign is optional and True by default. If set to False, suppresses the "-" sign for negative numbers and uses the parenthesized (...) form instead.
*****************
FloatingPoint is optional and True by default. If set to False, uses the European format (floating commas and "dot" separators), e.g. 1.234.567,89.
*****************
Prefix is optional and empty by default. Specifies a string prefix that will be automatically inserted in front of each number in the column.


0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question