主题:  请高手帮助,急!!

yukeiv

职务:普通成员
等级:1
金币:0.0
发贴:35
#12002/10/28 18:35:52
有高手知道为什么我设计的数据库中字段是货币型。如:123,321,333.00但在网页上却只能看到:123321333不符合财务标准。程序是用ASP写的。我想让它在网页上显示是123,333,333.00这样的格式。不但有“,”还要有".00" 我用的是acess而且在设计的时候我已经把字段属性设为(Currency)货币型了。但还是不行为什么?大哥帮忙!!!
源码:<%@LANGUAGE="VBSCRIPT"%>

<%
' *** Restrict Access To Page: Grant or deny access to this page
MM_authorizedUsers="1"
MM_authFailedURL="Login.asp"
MM_grantAccess=false
If Session("MM_UserName") <> "" Then
If (false Or CStr(Session("MM_UserAuthorization"))="") Or _
(InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization"))>=1) Then
MM_grantAccess = true
End If
End If
If Not MM_grantAccess Then
MM_qsChar = "?"
If (InStr(1,MM_authFailedURL,"?") >= 1) Then MM_qsChar = "&"
MM_referrer = Request.ServerVariables("URL")
if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" & Request.QueryString()
MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" & Server.URLEncode(MM_referrer)
Response.Redirect(MM_authFailedURL)
End If
%>
<%
' *** Edit Operations: declare variables

MM_editAction = CStr(Request("URL"))

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>

<%
' *** Redirect if userName exists
MM_flag="MM_insert"
If (CStr(Request(MM_flag)) <> "") Then
strSheetName=Request("SheetName") & ""
if Instr(strSheetName,"!")>0 or Instr(strSheetName,"@")>0 or Instr(strSheetName,"#")>0 or Instr(strSheetName,"$")>0 or Instr(strSheetName,"%")>0 or Instr(strSheetName,"^")>0 or Instr(strSheetName,"&")>0 or Instr(strSheetName,"*")>0 or Instr(strSheetName,"(")>0 or Instr(strSheetName,")")>0 or Instr(strSheetName,"-")>0 or Instr(strSheetName,"=")>0 or Instr(strSheetName,"\")>0 or Instr(strSheetName,",")>0 or Instr(strSheetName,".")>0 or Instr(strSheetName,"/")>0 or Instr(strSheetName,"?")>0 or Instr(strSheetName,"<")>0 or Instr(strSheetName,">")>0 or Instr(strSheetName,"[")>0 or Instr(strSheetName,"]")>0 or Instr(strSheetName,"{")>0 or Instr(strSheetName,"}")>0 or Instr(strSheetName,"|")>0 or Instr(strSheetName,"+")>0 or Instr(strSheetName,"~")>0 then
    Response.Redirect "TestManage.asp?Err=Char"
end if

MM_dupKeyRedirect="TestModify.asp"
MM_rsKeyConnection=MM_StudentConn_STRING
MM_dupKeyUserNamevalue = CStr(Request.Form("SheetName"))
MM_dupKeySQL="SELECT SheetName FROM TestName WHERE SheetName='" & MM_dupKeyUserNamevalue & "'"
MM_adodbRecordset="ADODB.Recordset"
set MM_rsKey=Server.CreateObject(MM_adodbRecordset)
MM_rsKey.ActiveConnection=MM_rsKeyConnection
MM_rsKey.Source=MM_dupKeySQL
MM_rsKey.CursorType=0
MM_rsKey.CursorLocation=2
MM_rsKey.LockType=3
MM_rsKey.Open
If Not MM_rsKey.EOF Or Not MM_rsKey.BOF Then
' the userName was found - can not add the requested userName
MM_qsChar = "?"
If (InStr(1,MM_dupKeyRedirect,"?") >= 1) Then MM_qsChar = "&"
MM_dupKeyRedirect = MM_dupKeyRedirect & MM_qsChar & "SheetName=" & MM_dupKeyUserNamevalue
Response.Redirect(MM_dupKeyRedirect)
End If
MM_rsKey.Close
End If
%>
<%
' *** Insert Record: set variables

If (CStr(Request("MM_insert")) <> "") Then

MM_editConnection = MM_StudentConn_STRING
MM_editTable = "TestName"
MM_editRedirectUrl = "TestManage.asp"
MM_fieldsStr = "TestName|value|SheetName|value"
MM_columnsStr = "TestName|',none,''|SheetName|',none,''"

' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")

' set the form values
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(i+1) = CStr(Request.Form(MM_fields(i)))
Next

' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If

End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it

If (CStr(Request("MM_insert")) <> "") Then

' create the sql insert statement
MM_tablevalues = ""
MM_dbvalues = ""
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
FormVal = MM_fields(i+1)
MM_typeArray = Split(MM_columns(i+1),",")
Delim = MM_typeArray(0)
If (Delim = "none") Then Delim = ""
AltVal = MM_typeArray(1)
If (AltVal = "none") Then AltVal = ""
EmptyVal = MM_typeArray(2)
If (EmptyVal = "none") Then EmptyVal = ""
If (FormVal = "") Then
FormVal = EmptyVal
Else
If (AltVal <> "") Then
FormVal = AltVal
ElseIf (Delim = "'") Then ' escape quotes
FormVal = "'" & Replace(FormVal,"'","''") & "'"
Else
FormVal = Delim + FormVal + Delim
End If
End If
If (i <> LBound(MM_fields)) Then
MM_tablevalues = MM_tablevalues & ","
MM_dbvalues = MM_dbvalues & ","
End if
MM_tablevalues = MM_tablevalues & MM_columns(i)
MM_dbvalues = MM_dbvalues & FormVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tablevalues & ") values (" & MM_dbvalues & ")"

If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

' 在DW代码的基础上用SQL语句实现向数据库中添加表

    strSubject="(StudentNum TEXT (8) CONSTRAINT MyFieldConstraint PRIMARY KEY,备用值空位1 Currency,备用值空位2 Currency,备用值空位3 LONG,备用值空位4 LONG,"
    strTemp=request("chkbox")
    if instr(strTemp,",")>0 then
        strSubject=strSubject & replace(strTemp,","," Currency,") & " Currency)"
    else
        strSubject=strSubject & strTemp & " Currency)"
    end if
    strSheetName = MM_dupKeyUserNamevalue
    MM_CreateTableConnection = MM_StudentConn_STRING
    MM_CreateTableQuery = "Create Table " & strSheetName & strSubject
    Set MM_CreateTableCmd = Server.CreateObject("ADODB.Command")
    MM_CreateTableCmd.ActiveConnection = MM_CreateTableConnection
MM_CreateTableCmd.CommandText = MM_CreateTableQuery
    MM_CreateTableCmd.Execute
MM_CreateTableCmd.ActiveConnection.Close
    
If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If

End If
%>
<%
set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_StudentConn_STRING
Recordset1.Source = "SELECT * FROM TestName ORDER BY id DESC"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()
Recordset1_numRows = 0
%>
<%
Dim Recordset2
Dim Recordset2_numRows

Set Recordset2 = Server.CreateObject("ADODB.Recordset")
Recordset2.ActiveConnection = MM_StudentConn_STRING
Recordset2.Source = "SELECT * FROM Subject ORDER BY ID ASC"
Recordset2.CursorType = 0
Recordset2.CursorLocation = 2
Recordset2.LockType = 1
Recordset2.Open()

Recordset2_numRows = 0
%>
<%
Dim Repeat1__numRows
Repeat1__numRows = -1
Dim Repeat1__index
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<%
Dim Repeat2__numRows
Dim Repeat2__index

Repeat2__numRows = -1
Repeat2__index = 0
Recordset2_numRows = Recordset2_numRows + Repeat2__numRows
%>
<%
' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters

' create the list of parameters which should not be maintained
MM_removeList = "&index="
If (MM_paramName <> "") Then MM_removeList = MM_removeList & "&" & MM_paramName & "="
MM_keepURL="":MM_keepForm="":MM_keepBoth="":MM_keepNone=""

' add the URL parameters to the MM_keepURL string
For Each Item In Request.QueryString
NextItem = "&" & Item & "="
If (InStr(1,MM_removeList,NextItem,1) = 0) Then
MM_keepURL = MM_keepURL & NextItem & Server.URLencode(Request.QueryString(Item))
End If
Next

' add the Form variables to the MM_keepForm string
For Each Item In Request.Form
NextItem = "&" & Item & "="
If (InStr(1,MM_removeList,NextItem,1) = 0) Then
MM_keepForm = MM_keepForm & NextItem & Server.URLencode(Request.Form(Item))
End If
Next

' create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL & MM_keepForm
if (MM_keepBoth <> "") Then MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
if (MM_keepURL <> "") Then MM_keepURL = Right(MM_keepURL, Len(MM_keepURL) - 1)
if (MM_keepForm <> "") Then MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)

' a utility function used for adding additional parameters to these strings
Function MM_joinChar(firstItem)
If (firstItem <> "") Then
MM_joinChar = "&"
Else
MM_joinChar = ""
End If
End Function
%>




费用表管理






<% if Request("Err")="Char" Then %>

<% End If %>













 


添加新费用表:


















费用表名称:

例如:现金流量控制表、材料费考核表
数据库对应的表名:

表名不能以数字或符号开头,必须以字母开头。

表名中不能含有符号或“!@#$%^&*()-+=|\,./?[]{}”等字符,为减少错误,请只用“字母+数字”的组合。




推荐命名规则:
部门+年度+费用表名

例如:hrcw2002xjllkz

     其中,“hrcw”表示哈热财务,“2002”表示2002年度,“xjllkz”表示现金流量控制表
费用表明细:
<% If Not Recordset2.EOF Or Not Recordset2.BOF Then
response.Write ""
While ((Repeat2__numRows <> 0) AND (NOT Recordset2.EOF))
    response.Write(""
    Repeat2__index=Repeat2__index+1
    Repeat2__numRows=Repeat2__numRows-1
    Recordset2.MoveNext()
Wend
response.Write("
")
    response.Write(Recordset2.Fields.Item("SubjectName").value)
    if Repeat2__numRows mod 8 =0 then response.write "
")
If (Recordset2.CursorType > 0) Then
Recordset2.MoveFirst
Else
Recordset2.Requery
End If
%>


费用表明细管理>>>
                <% Else %>
找不到任何费用表明细,请首先进入“费用表明细管理”模块添加费用表明细!
<% End If %>
                

>


        已有的费用表:

<% If Not Recordset1.EOF Or Not Recordset1.BOF Then %>








<%
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))
%>







<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Recordset1.MoveNext()
Wend
%>
序号 费用表名称 数据库对应表名 已有的费用表明细 操作
<%=(Recordset1.Fields.Item("id").value)%> <%=(Recordset1.Fields.Item("TestName").value)%> <%=(Recordset1.Fields.Item("SheetName").value)%>
<%
Dim rsSubject
Dim rsSubject_numRows

Set rsSubject = Server.CreateObject("ADODB.Recordset")
rsSubject.ActiveConnection = MM_StudentConn_STRING
rsSubject.Source = "SELECT * FROM " & Recordset1.Fields.Item("SheetName").value
rsSubject.CursorType = 0
rsSubject.CursorLocation = 2
rsSubject.LockType = 1
rsSubject.Open()

rsSubject_numRows = 0
response.Write("")
For i = 5 to rsSubject.Fields.Count - 1
    Response.write ""
    if (i+1-5)>0 and ((i+1-5) mod 8 =0) then response.write ""
next
response.Write("
" & rsSubject.Fields(i).Name & "
")
rsSubject.Close()
Set rsSubject = Nothing
%>
">修改 " onClick="return ConfirmDel()">删除



<% End If ' end Not Recordset1.EOF Or NOT Recordset1.BOF %>
<% If Recordset1.EOF And Recordset1.BOF Then %>

找不到任何费用表,请添加费用表!




<% End If ' end Recordset1.EOF And Recordset1.BOF %>






        
    


<%
Recordset1.Close()
%>
<%
Recordset2.Close()
Set Recordset2 = Nothing
%>



5D荣誉版主

职务:普通成员
等级:1
金币:10.0
发贴:271
#22002/10/28 18:46:23
FormatCurrency(字段,2,-1,-1,-2)
还的将你的计算机区域设置里的货币选项设为你所限定的格式



yukeiv

职务:普通成员
等级:1
金币:0.0
发贴:35
#32002/10/28 18:56:54
老大,我的计算机区域设置里的货币选项设为¥123,221.20为什么还是不行?



5D荣誉版主

职务:普通成员
等级:1
金币:10.0
发贴:271
#42002/10/28 19:03:08

是将数字分组设为123,456,789格式啊



yukeiv

职务:普通成员
等级:1
金币:0.0
发贴:35
#52002/10/28 19:14:10
是啊。我就象你说的这么设的为什么还是不行?我可能没有说明白。我在上面的源程序中用SQL创建的表字段,属性设为货币型,我在另外一个程序中显示这个字段,结果是12345678。没有“,”,也没有“.00”。为什么?



5D荣誉版主

职务:普通成员
等级:1
金币:10.0
发贴:271
#62002/10/29 8:31:20
当你要显示这个字段时
<%=FormatCurrency(字段,2,-1,-1,-2)%>就行,我刚在我机器上试过了可以的