我一直在寻找如何从经典的asp调用存储过程并将参数传递给它的方法,这是我的存储过程,可以正常工作

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 + '%'


和我到目前为止的vbscript代码-

Set objCon = CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.Recordset")
set objComm = CreateObject("ADODB.Command")

objCon.Open "Provider=SQLOLEDB.1;Password=xxxx;Persist Security Info=True;User ID=xxxx;Initial Catalog=Movies;Data Source=xxxx-PC"

objComm.ActiveConnection = objCon
objComm.CommandType = 4
objComm.CommandText = "Paging_Movies"

objRS.open objComm.CommandText, objCon

最佳答案

您正在寻找Parameters属性。

objComm.Parameters.Append objComm.CreateParameter("alphaChar", adChar, adParamInput)
objComm.Parameters("alphaChar") = "a"
objComm.Execute


哦,劳迪,我又在写VBScript。

10-07 15:54