ReportingAnalyst
MIS
Hi,
I am trying to get a results from a stored procedure instead of a previous SQL statement.
I am getting an error:
Error Type:
Microsoft VBScript compilation (0x800A0414)
Cannot use parentheses when calling a Sub
at this line:
My code is:
FYI, my stored procedure looks like this:
I am trying to get a results from a stored procedure instead of a previous SQL statement.
I am getting an error:
Error Type:
Microsoft VBScript compilation (0x800A0414)
Cannot use parentheses when calling a Sub
at this line:
Code:
.Parameters.Append.CreateParameter("@OwnerPayee",adInteger,adParamInput,,strUI)
My code is:
Code:
<%
Const adCmdStoredProc = 4
Const adInteger = 3
Const adVarChar = 200
Const adBSTR = 8
Const adBoolean = 11
Const adDouble = 5
Const adParamReturnValue = 4
Const adParamInput = 1
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.open "PROVIDER=SQLOLEDB;DATA SOURCE=Servername;UID=dbo;PWD=password;DATABASE=da tabase "
Set rsEmployee = Server.CreateObject("ADODB.Recordset")
Set cmd = Server.CreateObject("ADODB.Command")
strUI = 4655
With cmd
.ActiveConnection = Conn
'Specify name of stored procedure you wish to call
.CommandText = "sp_Org_Structure"
.CommandType = adCmdStoredProc
'Values needed ("@parameter_name",type_of_field,adParamInput,,value_being_passed)
.Parameters.Append.CreateParameter("@OwnerPayee",adInteger,adParamInput,,strUI)
End with
set rsEmployee = cmd.Execute
If rsEmployee.EOF and rsEmployee.BOF Then
Response.Write "No records found"
else
response.write "records found"
while not rsEmployee.EOF
response.write rsEmployee("Emp_Name") & "(" & rsEmployee("EmpID") & ")" & "<br>"
rsEmployee.MoveNext
wend
End If
rsEmployee.Close
set rsEmployee = Nothing
cmd.Close
Set cmd = Nothing
Conn.Close
Set Conn = Nothing
%>
FYI, my stored procedure looks like this:
Code:
CREATE PROCEDURE [dbo].[sp_Org_Structure]
@OwnerPayee int
as
SELECT DISTINCT AMP_AllMySubordinates_Postings.Owner_Payee,
AMP_AllMySubordinates_Postings.Owner_DateOfPost,
Employee.FirstName + ' ' + employee.LastName AS Emp_Name,
Employee.EmpID
FROM AMP_AllMySubordinates_Postings
INNER JOIN Employee ON
AMP_AllMySubordinates_Postings.Owner_Payee = Employee.UniqueIdentifier
WHERE AMP_AllMySubordinates_Postings.Owner_Payee = @OwnerPayee
AND AMP_AllMySubordinates_Postings.Owner_DateOfPost In
(Select MAX(AMP_AllMySubordinates_Postings.Owner_DateOfPos t) FROM Amp_AllMySubordinates_Postings WHERE owner_payee = @OwnerPayee);
GO