小编典典

经典asp存储过程参数

sql

我一直在寻找如何从经典的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

阅读 287

收藏
2021-04-22

共1个答案

小编典典

您正在寻找Parameters属性。

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

哦,劳迪,我又在写VBScript。

2021-04-22