|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Issue with returning Identity NumberI have a procedure in vb.net that needs to insert records into one
table and use the new key value to is link with a transaction in another. I have a stored procedure which inserts records in the first table and returns the @@IDENTITY. I have a class which runs the stored procedure and returns the value to my procedure. Everything appears to work just fine, but every so often something happens and the identity number is not returned. I end up with a key value in my second table that is no where near the value in the first. I would appreciate some help to figure out what is going on and where this number is coming from. I have my code snippet if some one responds to this and wants to see it. Thanks Charles I would use SCOPE_IDENTITY() instead of @@Identity which is a global
variable and not really helpful if some intervening operation changes the @@Identity value. -- Show quote____________________________________ William (Bill) Vaughn Author, Mentor, Consultant Microsoft MVP INETA Speaker www.betav.com/blog/billva www.betav.com Please reply only to the newsgroup so that others can benefit. This posting is provided "AS IS" with no warranties, and confers no rights. __________________________________ "Charles" <cba***@bjtsupport.com> wrote in message news:1140455469.657164.272080@g14g2000cwa.googlegroups.com... >I have a procedure in vb.net that needs to insert records into one > table and use the new key value to is link with a transaction in > another. I have a stored procedure which inserts records in the first > table and returns the @@IDENTITY. I have a class which runs the stored > procedure and returns the value to my procedure. > Everything appears to work just fine, but every so often something > happens and the identity number is not returned. I end up with a key > value in my second table that is no where near the value in the first. > I would appreciate some help to figure out what is going on and where > this number is coming from. > I have my code snippet if some one responds to this and wants to see > it. > > Thanks > Charles > |
|||||||||||||||||||||||