How to fetch the last inserted record in a particular table?

Answer Posted / raji22559

CommanObject.CommandText="Select @@Identity";

** Note: Over a given connection if any insert statement is
executed on a table with identity column , the back end
sql-server for the connection initializes a parameter by
name "@@Identity" with the value of Identity column for the
last inserted record.

Is This Answer Correct ?    18 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How is it possible to get 2 tables of data at a time by using data reader?

673


What is executequery?

685


Define table relations?

730


What are the types of databinding?

721


What is Data view?

771


Explain the overview of ado.net architecture?

696


Explain what are the steps to connect to a database?

712


What is executenonquery ado.net?

707


Which components of a data provider is used to retrieve, insert, delete, or modify data in a data source?

859


What is data relation?

677


Describe the command object and its method.

724


What are the different namespaces used in the project to connect the database? What data providers available in .net to connect to database?

1002


What are the different execute methods of Ado.Net?

726


Explain how to bind the controls(best practice) comboboxes to the data in the dataset?

753


What is fill method in ado.net?

713