Sql server 2005 我的电子商务网站不再显示价格了

Sql server 2005 我的电子商务网站不再显示价格了,sql-server-2005,asp-classic,Sql Server 2005,Asp Classic,亲爱的专家们,大家好 我有一个电子商务网站在 该网站使用Access作为后端数据库运行良好。 最近,我们把托管公司改为godaddy.com 我们将数据从Access迁移到SQL Server数据库,当然还将连接字符串更改为指向SQL Server db 从那时起,该网站现在显示的价格为0.00 我不知道是什么原因造成的 字段名是cprice。在Access db上,数据类型为Currency,在SQL Server上,数据类型为Money 我注意到的一件奇怪的事情是,在SQL Server d

亲爱的专家们,大家好

我有一个电子商务网站在

该网站使用Access作为后端数据库运行良好。 最近,我们把托管公司改为godaddy.com

我们将数据从Access迁移到SQL Server数据库,当然还将连接字符串更改为指向SQL Server db

从那时起,该网站现在显示的价格为0.00

我不知道是什么原因造成的

字段名是cprice。在Access db上,数据类型为Currency,在SQL Server上,数据类型为Money

我注意到的一件奇怪的事情是,在SQL Server db上,该值更像xx.xxxx

示例299.0000在Access db上,该值更像$299.00

有人能建议如何解决这个问题吗

更改连接字符串是否与此有关

如果需要,我可以提供一些asp代码示例。我使用的是经典的asp

'Response.Buffer = true
Dim catid, strcat
catid = Request.QueryString("id")
strcat = Request.QueryString ("cat")

If catid = "" OR (IsNumeric(catid) = false) Then
    Response.Redirect "index.asp"
End if

Dim catname, productslist
sub productInfo(connObj,category)
    q = chr(34)
    set cmd = server.CreateObject("ADODB.Command")
    cmd.ActiveConnection = connObj
    cmd.CommandText = "qryProdsCategory"
    cmd.CommandType = adCmdStoredProc
    set param = cmd.CreateParameter("theCategory",adInteger,adParamInput,4)
    cmd.Parameters.Append(param)
    cmd("theCategory") = Cint(category)
    set rs = server.CreateObject("ADODB.Recordset")
    set rs = cmd.Execute

    if not rs.EOF then
        catname = rs("catdescription")
    %>
        <table width='100%' border=0 cellspacing=0 cellpadding=0>
        <tr>
     <%
        i = 1
        while not rs.EOF
           id = RS("catalogID")
           'Response.write id
           'response.end
        %>
         <td class=bodytextcolor width='33%' align=center nowrap>
         <img src="img/small/<%=rs("cimageurl")%>" align="center" WIDTH='97' HEIGHT='125'>
         <br/><%=rs("cname")%>
          <br>Regular Price: <font color=red><%= FormatCurrency(rs("cprice"),2) %></font>
         <br/><font color=green>10 or more:</font>
         <font color=red><%=FormatCurrency(rs("cover10price"),2)%></font>
         <br/><font size=-1><a href="product.asp?id=<%=id%>">View Details</a></font>
         <br/>
         <font face="Verdana">
        <form name="_xclick" target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
          <input type="hidden" name="cmd" value="_cart">
          <input type="hidden" name="business" value="millennium2000@charter.net">
          <input type="hidden" name="item_name" value="<%=rs("cname")%>">
          <input type="hidden" name="amount" value="<%= FormatCurrency(rs("cprice"),2) %>">
            <table>
                <tr>
                    <td>Quantity: <input maxLength="6" Name="quantity" size=2 value="1" style="height: 2.2em; border: 1px solid Black; background: ButtonFace;">
          <input type="image" src="images/button_in_cart.jpg" border="0" name="submit" alt="PayPal">
          <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"></td>
                </tr>
        </table>
          <input type="hidden" name="add" value="1">
         </form></td>
       <%

            if (i mod 3) = 0 then
                Response.write "</td></tr>"
            end if
            i = i + 1
            rs.MoveNext
        wend

    else
        Response.write "Product information not found."
        catname = "Error"
    end if
        Response.write "productslist: "
    rs.Close
    set rs = nothing
    set cmd = nothing

end sub

%>

--stored procedure
USE [scartmil]
GO

/****** Object:  StoredProcedure [dbo].[qryProdsCategory]    Script Date: 02/12/2012 19:08:25 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

/****** Object:  StoredProcedure [dbo].[NewStoredProcedure]    Script Date: 02/10/2012 19:36:49 ******/
ALTER PROCEDURE [dbo].[qryProdsCategory](@theCategory int)
AS
SELECT products.*, products.ccategory, categories.catdescription
FROM categories INNER JOIN products ON categories.categoryID = products.ccategory
WHERE (((products.ccategory)=@theCategory));

GO

从Access迁移到SQL时,您会面临许多转换问题,我相信您的问题是在迁移级别,SQL中的字段可能是money或numeric18,2,您可能需要重新划分它,或者如果更改字段的数据类型,SQL是否会保留值


另外,请确保在SQL中也配置了任何标识数据类型,至少根据经验,对SQL的访问并不能很好地解决这一问题。

在SQL server中,什么是数据类型?钱最好在数据绑定的地方提供代码。我的第一个猜测是数据类型的差异。可能在您处理价格的代码中的某个地方,这种破坏会导致采用并使用默认的0值。感谢大家的及时响应。我已经发布了上面的代码。您需要显示过程qryProdsCategory的文本。另外,您正在显示的许多ASP代码基本上是无关的。事实上,可能是全部。但是,是否可能您也移动了网站,并且它现在位于具有不同区域设置的服务器上,例如,而不是。对于小数?我认为您需要调整格式CurrencyCorve10Price,2。我猜FormatCurrency总是返回0。正如您在我的原始帖子中看到的,我改为sql server数据类型Money,它显示的值类似于989.0000。我现在试试数字,看看是否有用。仅供参考,我确实尝试了小数点18,2货币字段之所以这样做是因为SQL中定义了小数点,这就是为什么我通常使用数字18,2,2是小数点后的小数点。Zee,我尝试过,但不幸的是,没有帮助-仍然是0.00,在转换过程中或在应用程序中,它何时更改为0.00?在应用程序中。它显示转换后db上的正确数量。我注意到的唯一区别是,假设Access db中的金额为48.00美元,SQL中显示为48.00美元。在将数据类型更改为currency18,2之后