ADODB命令中的参数分配问题

时间:2021-06-18 01:49:57

We use an ADODB command to perform queries (call stored procedures) on our SQL Server 2000 database, using SQLOLEDB driver.

我们使用ADODB命令使用SQLOLEDB驱动程序在SQL Server 2000数据库上执行查询(调用存储过程)。

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.

此代码实际工作我们的生产服务器上,但对于一些奇怪的原因,它不符合我们的开发服务器上运行,并生成该错误:应用程序使用了错误类型为当前操作的值,当我们分配一个值(含小数部分,比如说“12.75”之类的字符串到数据类型货币参数。

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.

dev和prod上的代码完全相同。这可能与区域设置,ADODB语言,thr OS语言或其他一些Windows组件有关吗?因为它是经典的ASP代码,我们已经看过Session.LCID,但它们在两台服务器上是相同的,所以我们现在一无所知。

Have any idea ?

有什么想法吗?

2 个解决方案

#1


2  

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.

是否可以使用不同的基本语言或其他区域设置设置开发服务器?只是为了踢,尝试分配值12,75而不是12.75。

#2


1  

From the MS KB

来自MS KB

Parameters.refresh will fail in some situations or return information that is not entirely correct. Parameters.refresh is particularly vulnerable when used on ASP pages.

在某些情况下,Parameters.refresh将失败或返回不完全正确的信息。在ASP页面上使用时,Parameters.refresh特别容易受到攻击。

There is a known issue regarding parameter direction when using Parameters.refresh from Classic ASP. MS guidance is to manually generate the parameters.

当使用来自Classic ASP的Parameters.refresh时,存在关于参数方向的已知问题。 MS指导是手动生成参数。

http://support.microsoft.com/kb/183008 http://support.microsoft.com/kb/174223

#1


2  

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.

是否可以使用不同的基本语言或其他区域设置设置开发服务器?只是为了踢,尝试分配值12,75而不是12.75。

#2


1  

From the MS KB

来自MS KB

Parameters.refresh will fail in some situations or return information that is not entirely correct. Parameters.refresh is particularly vulnerable when used on ASP pages.

在某些情况下,Parameters.refresh将失败或返回不完全正确的信息。在ASP页面上使用时,Parameters.refresh特别容易受到攻击。

There is a known issue regarding parameter direction when using Parameters.refresh from Classic ASP. MS guidance is to manually generate the parameters.

当使用来自Classic ASP的Parameters.refresh时,存在关于参数方向的已知问题。 MS指导是手动生成参数。

http://support.microsoft.com/kb/183008 http://support.microsoft.com/kb/174223