我一直在寻找如何从经典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
答案 0 :(得分:5)
您正在寻找参数属性。
objComm.Parameters.Append objComm.CreateParameter("alphaChar", adChar, adParamInput)
objComm.Parameters("alphaChar") = "a"
objComm.Execute
哦,劳迪我又在写VBScript。
答案 1 :(得分:1)
您可以传递如下所示的参数
LInk for it:http://www.devguru.com/technologies/ado/quickref/command_createparameter.html
Set objParameter = objCommand.CreateParameter
objParameter.Name = "alphaChar"
objParameter.Type = adChar
objParameter.Direction = adParamInput
objParameter.Value = "a"
or
Set objParameter = objCommand.CreateParameter ("alphaChar", adChar, adParamInput, "a")