-1
我以前曾问过类似的问题,虽然我试图解决我以前的代码,但现在我得到了一个错误“参数是错误的类型,超出了可接受的范围,或相互冲突“。我想传递一个字符作为参数来查询数据库,然后使用记录集打印出一个网页。我的经典ASP代码低于传递参数到存储过程中经典的asp
Set objCon = CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.Recordset")
set objComm = CreateObject("ADODB.Command")
objCon.ConnectionString = "Provider=SQLOLEDB.1;Password=xxxx;Persist Security Info=True;User ID=xxxx;Initial Catalog=Movies;Data Source=xxxx-PC"
objCon.open objCon.ConnectionString
objComm.ActiveConnection = objCon.ConnectionString
objComm.CommandText = "Paging_Movies"
objComm.CommandType = adCmdStoredProc
Set objParameter = objComm.CreateParameter
objParameter.Name = "alphaChar"
objParameter.Type = adChar
objParameter.Direction = adParamInput
objParameter.Value = "a"
objComm.Parameters.Append objParameter
set objRs = objComm.Execute
而且我的存储过程是如下 -
CREATE PROCEDURE Paging_Movies
@alphaChar char(1)
AS
if @alphaChar = '#'
select * from Movies where movies like '[^a-z]%'
else
select * from Movies where movies like @alphaChar + '%'
不幸的是我最终的类型不匹配? – 2011-06-16 08:55:26
@ kurupt89:尝试指定1的长度? [见本手册页。](http://www.w3schools.com/ado/met_comm_createparameter.asp) – Andomar 2011-06-16 09:13:19
感谢你的回复帮助我找到答案。我不得不将adChar和adParamInput更改为数字表示形式 – 2011-06-16 09:16:58