【问题标题】:Get scope_identity returned value获取 scope_identity 返回值
【发布时间】:2010-09-24 14:32:22
【问题描述】:

如何在我的 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?

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

谢谢

【问题讨论】:

    标签: asp.net vb.net scope-identity


    【解决方案1】:

    您是否在 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
    

    不确定是否需要参数方向属性。

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-02-19
      • 1970-01-01
      • 2011-08-29
      • 1970-01-01
      • 1970-01-01
      • 2015-09-05
      • 1970-01-01
      相关资源
      最近更新 更多