Locking DB for a short time

J

Joe

I am sure this is an old issue for ASP veterans, but I come from a
Cold Fusion background, in which what I will ask below can be easily
done.

Let's say I have two tables named "Companies" and "Users"
respectively.

In the Companies DB, the column with the unique ID and primary key is
called "CompID",
and is Auto Number.

Many users can be linked to a single company. This link is determined
by a column
called also CompID in the Users table.

Now, sometimes a user will specify a new company that's not in the
table Companies,
which means that I have to insert a new record in the Company table,
creating thus a new CompID which I then have to read -Max(CompID)- and
update the Users.CompID with this value.

Between the insertion of the new record and the update other users of
the database must be
prevented from making changes. How does one do that? I've heard stuff
about using
Application.Lock, but doesn't that work only with Application
variables? Or can one just go and use code like below:

<%
Application.Lock

SQL stuff ...
other SQL stuff ..

Application.Unlock
%>

Please, help. Thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,781
Messages
2,569,615
Members
45,294
Latest member
LandonPigo

Latest Threads

Top