2010-09-24 60 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