sql server - Get ID of newly inserted record in SQL database -


i using detailsview insert records database, confirmation appear after insert displays id of new record. using following code:

protected sub detailsview1_iteminserted(sender object, e detailsviewinsertedeventargs) handles detailsview1.iteminserted       dim strconnstring string = configurationmanager.connectionstrings("houses").connectionstring     dim con new sqlconnection(strconnstring)     dim cmd new sqlcommand()      cmd.commandtext = "select @@identity"      cmd.connection = con     try         con.open()         dim obj object = cmd.executescalar()         response.write("<div class=newlisting> record ")         response.write("<span class=deletedlistinghighlight>")         response.write(obj.tostring)         response.write("</span> added.</div>")       catch ex exception         throw ex             con.close()         con.dispose()     end try  end sub 

the confirmation appears @ top of page not show id , i'm not sure missing.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -