When you run an INSERT INTO SqlDataSource object through the features, perhaps related to a FormView, can be very useful to go back to the key just entered in the table.
Of course I am referring to a table I have an identity as a key field.
Here's how:
INSERT INTO [TABLE] ([field])
VALUES ([@ PARAMETERS]) SELECT @ NewID = SCOPE_IDENTITY () Add
between
InsertParameter
:
Name = "NewID" Direction = "OUTPUT" Type = "Int32"
Now event Protected Sub SqlDSClient_Inserted you can retrieve the value:
e.Command.Parameters ("@ NewID ").Value
0 comments:
Post a Comment