sp;As Object, ByVal e As ObjectDataSourceStatusEventArgs)
Response.Write("Record Count: " & Server.HtmlEncode(e.OutputParameters("totalCount")))
End Sub
Protected Sub ObjectDataSource1_Updated(ByVal sender As Object, ByVal e As ObjectDataSourceStatusEventArgs)
Response.Write("Rows Affected: " & Server.HtmlEncode(e.ReturnValue) & "<br/>")
End Sub
<asp:ObjectDataSource ID="ObjectDataSource1" ……>
<UpdateParameters>
<asp:Parameter Name="ContactName" Type="String" />
</UpdateParameters>
<SelectParameters>
<asp:Parameter Direction="Output" Name="totalCount" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
输出参数的另一种通常的用途是检索插入数据库的行的主键值,而该主键列是一个标识列(在这种情况下,在插入操作的参数中没有指定键值,该键值是在插入操作发生时,数据库服务器自动生成的)。下面的例子演示了这种技术。
Protected Sub SqlDataSource1_Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs)
Response.Write("Record Inserted: " & Server.HtmlEncode(e.Command.Parameters("@ContactID").Value) & "<br/>")
End Sub
<asp:SqlDataSource ID="SqlDataSource1" ……>
……
<InsertParameters>
<asp:Parameter Name="contactName" Type="String" />
<asp:Parameter Direction="Output" Name="contactID" Type="Int32" />
</InsertParameters>
</asp:SqlDataSource>