Article ID: 320141 - Last Review: December 26, 2003 - Revision: 5.4 HOW TO: Retrieve an Identity Value from a Newly Inserted Record from SQL Server by Using Visual Basic .NETThis article was previously published under Q320141 On This PageSUMMARY This step-by-step article describes how to retrieve the
identity value when you add a record into a SQL Server table with an identity
field. RequirementsThis sample uses the Northwind database in SQL Server and retrieves the identity values only for DataTables with no child tables. It can also be used with MSDE; however, the Northwind database is not included with MSDE. For information about how to use this procedure with MSDE, see the Troubleshooting section of this article. A SQL Server identity field is an auto number field that you can define an incremental value for. For this reason, you cannot insert or update a value in this field as long as Identity_ insert is off, which is the default for a SQL Server identity field. Sample
TroubleshootingBefore you use this procedure, with MSDE you must use Data Transformation Services (DTS) to import the Northwind database for SQL Server or Microsoft Access.REFERENCESFor additional information about returning the identity
value for child records, click the article numbers below to view the articles
in the Microsoft Knowledge Base: 320301
(http://support.microsoft.com/kb/320301/EN-US/
)
HOWTO: Update Parent-Child Data with Identity column from a Windows Forms application via a Web Service
For additional information about how to use DTS,
click the article number below to view the article in the Microsoft Knowledge
Base: 242377
(http://support.microsoft.com/kb/242377/EN-US/
)
How to Use Data Transformation Services (DTS)
For additional information about converting a Microsoft Access database to
SQL Server, click the following article number to view the article in the Microsoft Knowledge Base:
237980
(http://support.microsoft.com/kb/237980/EN-US/
)
HOW TO: Convert an Access Database to SQL Server
For additional information about how to
retrieve identity columns in Visual Basic 6.0, click the following article
number to view the article in the Microsoft Knowledge Base: 170147
(http://support.microsoft.com/kb/170147/EN-US/
)
HOWTO: Retrieve Identity Column After Insert Using RDO
APPLIES TO
| Article Translations
|
Back to the top
