开发者

Get scope_identity returned value

开发者 https://www.devze.com 2023-01-17 23:43 出处:网络
How can i get the scope identity parameter in my vb code. I have this so far.... InsertCommand=\"INSERT INTO [table_name] ([title], [subtitle], [description], [image1], [image1_caption], [image2], [p

How can i get the scope identity parameter in my vb code. I have this so far....

    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); SE开发者_JS百科LECT @NewID = SCOPE_IDENTITY()"

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

How can i retreive this ID, in the DetailsView1_ItemInserted?

If you need anymore info let me know.

Thanks


Did you try this in the ItemInserted event handler?

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

Not sure if you need Parameter Direction attribute.

Check out this MSDN article, they do exactly what you are attempting.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消