views:

19

answers:

1

Hey All,

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); SELECT @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

A: 

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

RPM1984