0

如何在我的 vb 代码中获取范围标识参数。到目前为止我有这个....

    InsertCommand="INSERT INTO [table_name] ([title], [subtitle], [description], [image1], [image1_caption], [image2], [pdf], [meta_description], [meta_keywords]) VALUES (@title, @subtitle, @description, @image1, @image1_caption, @image2, @pdf, @meta_description, @meta_keywords); SELECT @NewID = SCOPE_IDENTITY()"

<asp:Parameter Direction="Output" Name="NewID" Type="Int32" />

如何在 DetailsView1_ItemInserted 中检索此 ID?

如果您需要更多信息,请告诉我。

谢谢

4

1 回答 1

0

您是否在 ItemInserted 事件处理程序中尝试过这个?

Sub EmployeeDetailsSqlDataSource_OnInserted(sender As Object, e As SqlDataSourceStatusEventArgs)
    Dim command As System.Data.Common.DbCommand = e.Command  
    EmployeesDropDownList.DataBind()
    EmployeesDropDownList.SelectedValue = _
      command.Parameters("@NewID").Value.ToString()
    EmployeeDetailsView.DataBind()
End Sub

不确定是否需要 Parameter Direction 属性。

查看这篇 MSDN 文章,它们完全符合您的要求。

http://msdn.microsoft.com/en-us/library/xt50s8kz(VS.80).aspx

于 2010-09-24T23:46:56.967 回答