Friday, 17 August 2012

How to show last inserted record primary key if some fields already exists in database:

Hie... i gone through and got error today that if i'm inserting record it even exists in database i want to insert it and get the last updated record primary key then its better to use the @@Identity for that or else i 've  an simple technique for that...
Nothing we've to do, just save the system current Date while saving the record then get that record with help of the date and with corresponding  Email.

           info.dateandtime =DateTime.Now.ToString();

        
  string getrecord = "select id from tblcontact where email= '" + info.email + "' and  dateandtime='" + info.dateandtime + "'";

Will helps you.... or else use @@identity 

1 comment: