Retriving data after and Update SQL command

  • Thread starter Thread starter Rodrigo Caixeta
  • Start date Start date
R

Rodrigo Caixeta

Hi everybody. I had a problem. I have a field that is an
global counter. When a user adds a new object I need to
get a new sequencial code. To prevent against a running
condition that potentially can happen when two or more
stations adds an object together I made an SQL that
updates the table that controls the identifier but I can´t
retrive its value in .NET. How can I do it??

SQL:
UPDATE SYS_SEQUENCE SET NextNumber = NextNumber + 1

I need to known the NextNumber that was increased by the
database.

thanks,

Rodrigo
 
If you are performing your SQL inside of a stored
procedure, you can just make the NextNumber an OUTPUT
parameter and retrieve it. If not you could create a
command object and call the execute scalar method to
retrieve the single value back.

Hope this Helps.

Bart A. Robinson, MCP
 
Back
Top