![](/img/trans.png)
[英]Dataset: How to capture the primary key value returned by SELECT SCOPE_IDENTITY()?
[英]Get scope_identity returned value
我如何在我的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?
如果您需要更多信息,请告诉我。
谢谢
您是否在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/zh-CN/library/xt50s8kz(VS.80).aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.