Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Sql Server Lock System

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-07-15 : 08:21:24
Antony Christopher writes "sir,
I am new in sqlserver. I am developing one application for a multiuser system in VB with sqlserver. In that one part is member registration. When I open this form it will create a member id(total record no +1). At the same time other user also using the same operation. So this time also the member id is same. How to solve this problem. Please give me an Idea."

Nazim
A custom title

1408 Posts

Posted - 2002-07-15 : 08:40:07

begin tran
update tablename set @id = nextid + 1, nextid = nextid + 1
insert record
commit tran


The update will lock the table until the transaction is commited thereby insuring no other user gets the same id.


HTH

-------------------------
What lies behind you and what lies ahead of you are small matters compared to what lies within you.-Ralph Waldo Emerson
Go to Top of Page
   

- Advertisement -