Article ID: 192667
Article Last Modified on 11/14/2001
Create PROCEDURE GetAuthors
(
@lname varchar(40),
@state char(2)
)
AS
SELECT * FROM Authors
WHERE au_lname LIKE '%' + @lname + '%' AND state = @state
RETURN @@ROWCOUNT
<% thisPage.createDE %>If your page does not have the scripting object model enabled, then you would use the following code (this would also work on a page with the scripting object model enabled):
<%
Set DE = Server.CreateObject("DERuntime.DERuntime")
DE.Init(Application("DE"))
%>
<% DE.AuthorSearch "gr", "CA" %>
<%
Set objRS = DE.Recordsets("AuthorSearch")
%>
You could also append "rs" to the data command name to access the returned result set as in:<% Set objRS = DE.rsAuthorSearch %>
<%
Set objCMD = DE.Commands("AuthorSearch")
RowCount = objCMD.Parameters("RETURN_VALUE")
%>
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<%
'Create the Data Environment object
Set DE = Server.CreateObject("DERuntime.DERuntime")
DE.Init(Application("DE"))
'Run the command
DE.AuthorSearch "gr", "CA"
'Access the returned value and display it
Set objCMD = DE.Commands("AuthorSearch")
RowCount = objCMD.Parameters("RETURN_VALUE")
Response.Write "<H3>" & RowCount & " records returned</H3>"
'Access the resultset and write the Recordset out in an HTML table
Set objRS = DE.Recordsets("AuthorSearch")
Response.Write "<table border=1 cellpadding=4 cellspacing=4>"
Response.Write "<tr>"
For Each fld In objRS.Fields
Response.Write "<td><b>" & fld.Name & "</b></td>"
Next
Response.Write "</tr>"
Do While Not objRS.EOF
Response.Write "<tr>"
For Each fld In objRS.Fields
Response.Write "<td>" & fld.Value & "</td>"
Next
Response.Write "</tr>"
objRS.MoveNext
Loop
Response.Write "</table>"
%>
</BODY>
</HTML>
190762 PRB: Cannot Access a Stored Procedure's Return Value from DTC
Keywords: kbhowto kbstoredproc kbdatabase KB192667