I have an insert command for which I need the identity row from.
<asp:SqlDataSource ID="dsUser" runat="server" ConnectionString="<%$ ConnectionStrings:Link %>"
DeleteCommand="DELETE FROM User WHERE (uID = @uID)"
InsertCommand="INSERT INTO User(uID, FirstName, LastName, UserLogin, UserPassword, UserEmail) VALUES (NEWID(), @FirstName, @LastName, @UserLogin, @UserPassword, @UserEmail) SET @NewUserId=SCOPE_IDENTITY();"
<DeleteParameters>
<asp:Parameter Name="uID" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="FirstName" />
<asp:Parameter Name="LastName" />
<asp:Parameter Name="UserLogin" />
<asp:Parameter Name="UserPassword" />
<asp:Parameter Name="UserEmail" />
<asp:Parameter DbType="Guid" Direction="Output" Name="NewUserId" />
</InsertParameters>
</asp:SqlDataSource>
I'm trying to access the NewUserId
when the dsUser
value is inserted.
Private Sub dsUser_Inserted(sender As Object, e As SqlDataSourceStatusEventArgs) Handles dsUser.Inserted
Dim dvarl = e.Command.Parameters("@NewUserId").Value
Response.Redirect("editUser.aspx?uid=" + e.Command.Parameters("@NewUserId").Value)
End Sub
Once the data is inserted I want to redirect to the edit screen of the newly added User.
Debugging this doesn't really give any clues as to why the output param is not being SET
properly
I'm making progress debugging and found a new error message:
Which results: Operand type clash: numeric is incompatible with uniqueidentifier