问题
I have an Oracle 10g database with a field defined as NUMBER. I am converting a classic ASP (vbscript) from inline sql to parameterized. I cannot get the ADO.PARAMETER to map to a NUMBER. All I get is "Parameter object is improperly defined. Inconsistent or incomplete information was provided." I've tried decimal, numeric, with precision and scale, int, bigint, varchar, sizes and everything combination I can think of.
Dim param
Set param = Server.CreateObject("ADODB.Parameter")
param.Type = ? ' adDecimal
param.Precision = ? ' 38
param.NumericScale = ? ' 0
param.size = ?
.Value = MYNUMBER
Can someone tell me the type, precision, scale, size etc that I need?
回答1:
I would consider using the CreateParameter()
method of the ADODB.Command
object to build the parameters correctly. It's likely not the data type you are passing or the precision etc. that is the problem, rather it will be missing properties of the Parameter
object not being set (such as Direction
for example) or the Named Constants are not defined.
With that in mind for this particular example I looked up the expected data type Named Constant for Oracle's NUMBER
data type and according to Carl Prothman - Data Type Mapping (an excellent resource for mapping ADO constants to various data sources) you should be using adNumeric
which is 131
. Armed with that information I would build the parameter like so;
<%
Dim cmd: Set cmd = Server.CreateObject("ADODB.Command")
With cmd
...
'Define parameters
Call .Parameter.Append(.CreateParameter("par1", adNumeric, adParamInput, 9))
...
'Set Parameter values
.Parameter("par1").Value = MYNUMBER
...
End With
%>
...
- denotes assumed code for building the ADODB.Command
object.
Useful Links
- A: ADODB.Parameters error '800a0e7c' Parameter object is improperly defined. Inconsistent or incomplete information was provided (in case the cause is you don't have the named constants defined).
- A: How to use ASP variables in SQL statement (more complete example of using the
ADODB.Command
object).
来源:https://stackoverflow.com/questions/43214270/classic-asp-ado-parameter-mapping-to-oracle-10g-number-datatype