2010-09-24 61 views
0

如何获取我的vb代码中的作用域标识参数。我到目前为止......获取scope_identity的返回值

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" /> 

我该如何检索这个ID,在DetailsView1_ItemInserted?

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

谢谢

回答

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 

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

看看这个MSDN文章,他们做你正在尝试。

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