Suppose I am retrieving records from SQL Server using a stored procedure named PaySlip. Now if I am using the RECORDSET object, I can display all the records in a web page by using
<%
Do Until(objRS.EOF)
Response.Write(objRS("FieldName1"
)
Response.Write(objRS("FieldName2"
)
Response.Write(objRS("FieldName3"
)
objRS.MoveNext
Loop
%>
But how do I display the records if I am using the COMMAND object? For eg. if I have the following ASP code:
<%
Dim objCmd
Set objCmd=Server.CreateObject("ADODB.COMMAND"
objCmd.ActiveConnection=objConn
objCmd.CommandText="PaySlip"
objCmd.CommandType=adCmdStoredProc
objCmd.Parameters.Append objCmd.CreateParameter("@ccode",200,1,5,strCCode)
objCmd.Parameters.Append objCmd.CreateParameter("@month",3,1,5,arrPeriod(0))
objCmd.Parameters.Append objCmd.CreateParameter("@year",3,1,5,arrPeriod(1))
objCmd.Execute()
%>
Also when should the RECORDSET object be used & when should the COMMAND object be used if a stored procedure is used? Are there any advantages/disadvantages of using one over the other?
Thanks,
Arpan
<%
Do Until(objRS.EOF)
Response.Write(objRS("FieldName1"
Response.Write(objRS("FieldName2"
Response.Write(objRS("FieldName3"
objRS.MoveNext
Loop
%>
But how do I display the records if I am using the COMMAND object? For eg. if I have the following ASP code:
<%
Dim objCmd
Set objCmd=Server.CreateObject("ADODB.COMMAND"
objCmd.ActiveConnection=objConn
objCmd.CommandText="PaySlip"
objCmd.CommandType=adCmdStoredProc
objCmd.Parameters.Append objCmd.CreateParameter("@ccode",200,1,5,strCCode)
objCmd.Parameters.Append objCmd.CreateParameter("@month",3,1,5,arrPeriod(0))
objCmd.Parameters.Append objCmd.CreateParameter("@year",3,1,5,arrPeriod(1))
objCmd.Execute()
%>
Also when should the RECORDSET object be used & when should the COMMAND object be used if a stored procedure is used? Are there any advantages/disadvantages of using one over the other?
Thanks,
Arpan