ADODB 命令中的参数分配问题
我们使用 SQLOLEDB 驱动程序,使用 ADODB 命令在 SQL Server 2000 数据库上执行查询(调用存储过程)。
在我们的一台服务器上,当我们分配参数值时遇到问题。事情是这样的:
Set conn = Server.CreateObject("ADODB.Connection")
conn.CommandTimeout = 0
conn.ConnectionTimeout = 15
conn.Mode = 1 ' adModeRead
conn.ConnectionString = connectionString ' SQLOLEDB
conn.CursorLocation = 3 ' adUseClient
conn.Open
Set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = conn ' previously created connection
cmd.CommandType = 4 ' adCmdStoredProc
cmd.CommandText = "dbo.StoredProcedureName"
cmd.CommandTimeout = 0
cmd.Parameters.Refresh ' Get the parameters info from the database
' Pseudo code here :
Foreach cmd.parameters
cmd.parameters(index).value = somevalue
Next
这段代码实际上可以在我们的生产服务器上运行,但由于某些奇怪的原因,它不能在我们的开发服务器上运行并生成此错误:应用程序在当前操作中使用了错误类型的值 当我们将一个值(包含小数部分,例如“12.75”之类的字符串)分配给数据类型 Money 参数时。
开发版和生产版上的代码完全相同。这是否与区域设置、ADODB 语言、操作系统语言或其他一些 Windows 组件有关?因为它是经典的 ASP 代码,我们已经查看了 Session.LCID,但它们在两台服务器上是相同的,所以我们现在一无所知。
有什么想法吗?
We use an ADODB command to perform queries (call stored procedures) on our SQL Server 2000 database, using SQLOLEDB driver.
On one of our server we have issues when we assign parameter values. Here's how it goes :
Set conn = Server.CreateObject("ADODB.Connection")
conn.CommandTimeout = 0
conn.ConnectionTimeout = 15
conn.Mode = 1 ' adModeRead
conn.ConnectionString = connectionString ' SQLOLEDB
conn.CursorLocation = 3 ' adUseClient
conn.Open
Set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = conn ' previously created connection
cmd.CommandType = 4 ' adCmdStoredProc
cmd.CommandText = "dbo.StoredProcedureName"
cmd.CommandTimeout = 0
cmd.Parameters.Refresh ' Get the parameters info from the database
' Pseudo code here :
Foreach cmd.parameters
cmd.parameters(index).value = somevalue
Next
This code actually works on our production server, but for some odd reasons it does not work on our dev server and generates this error : Application uses a value of the wrong type for the current operation when we assign a value (which contain a decimal part, let's say a string like "12.75") to a datatype money parameter.
The code is exactly the same on dev and on prod. Do this could have something to do with regional settings, language of ADODB, language of thr OS or some other Windows component ? Because it is classic ASP code we already looked at Session.LCID but they are the same on both servers, so we are clueless right now.
Have any idea ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
开发服务器是否可以使用不同的基本语言或其他区域设置进行设置?只是为了好玩,尝试分配值 12,75 而不是 12.75。
Is it possible the dev server is set up with a different base language or other regional settings? Just for kicks try assigning the value 12,75 instead of 12.75.
来自 MS 知识库
使用经典 ASP 中的Parameters.refresh 时,存在一个有关参数方向的已知问题。 MS指导是手动生成参数。
http://support.microsoft.com/kb/183008
http://support.microsoft.com/kb/174223
From the MS KB
There is a known issue regarding parameter direction when using Parameters.refresh from Classic ASP. MS guidance is to manually generate the parameters.
http://support.microsoft.com/kb/183008
http://support.microsoft.com/kb/174223