Reputation: 1592
I've been looking around how to call a stored procedure from classic asp and pass a parameter into it below is my stored procedure which works fine
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 + '%'
and my vbscript code so far -
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
Upvotes: 4
Views: 5374
Reputation: 176896
You can pass the paramter like as below
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")
Upvotes: 1
Reputation: 32522
You're looking for the Parameters property.
objComm.Parameters.Append objComm.CreateParameter("alphaChar", adChar, adParamInput)
objComm.Parameters("alphaChar") = "a"
objComm.Execute
Oh Lawdy I'm writing VBScript again.
Upvotes: 5