O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Retrieve the Unique ID for a New Record in a DataSet

Problem

When you perform an update with the DataAdapter, you want the ID numbers for newly added records to be inserted into the DataSet.

Solution

Use a database stored procedure that returns this information in an output parameter, and map the parameter to the appropriate column.

Discussion

Recipe Retrieve the Unique ID for a New Record demonstrates how to return unique ID information with a stored procedure and configure the ADO.NET database command accordingly. This recipe shows how you can use this command with a DataSet so that the retrieved ID information is applied automatically to the appropriate field in the DataSet.

First you must map the parameters in the command to the fields in the

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required