Hi guys,
I have a web application that insert Clients info into the Database, the
Apllication is accesed by several user at the same time, the Client Info is
divide by 3 tables (Client, Product and 1 that combine the Client and
Product and having all info for how the client bought the product)
My question is: HOW can I know for sure that the script is not accesed by 2
diferent users?
WHY:
The script looks like this
INSERT blablabla INTO tblClients
INSERT blablabla INTO tblProduct
INSERT idClient, idProduct, blablabla INTO tblSales
idClient and idProduct is the @@identity from thoose inserts...
the question is How do I know for sure that tblSales have the right idClient
and idProduct and not from other client that other user is inserting in that
percision time?
I use Application.Lock() and Application.UnLock() before and after I execute
the script, but is this work?
thank you
--
Bruno Alexandre
(Sintra, PORTUGAL) 4 1126
"Bruno Alexandre" <br********@filtrarte.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... the question is How do I know for sure that tblSales have the right idClient and idProduct and not from other client that other user is inserting in that percision time?
Use a stored procedure and surround the INSERT statements with a
transaction.
That's why you dont use the AUTONumber/Identity.
Instead use your own table to store the ID.
Call the Key table to get the next ID
Increment the Key table
Use the new ID.
You can get a new key anytime then.
--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
"Bruno Alexandre" wrote: Hi guys,
I have a web application that insert Clients info into the Database, the Apllication is accesed by several user at the same time, the Client Info is divide by 3 tables (Client, Product and 1 that combine the Client and Product and having all info for how the client bought the product)
My question is: HOW can I know for sure that the script is not accesed by 2 diferent users?
WHY: The script looks like this INSERT blablabla INTO tblClients
INSERT blablabla INTO tblProduct
INSERT idClient, idProduct, blablabla INTO tblSales
idClient and idProduct is the @@identity from thoose inserts...
the question is How do I know for sure that tblSales have the right idClient and idProduct and not from other client that other user is inserting in that percision time?
I use Application.Lock() and Application.UnLock() before and after I execute the script, but is this work?
thank you
--
Bruno Alexandre (Sintra, PORTUGAL)
Check out the SCOPE_IDENTITY in the Books Online.
"Bruno Alexandre" <br********@filtrarte.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... Hi guys,
I have a web application that insert Clients info into the Database, the Apllication is accesed by several user at the same time, the Client Info is divide by 3 tables (Client, Product and 1 that combine the Client and Product and having all info for how the client bought the product)
My question is: HOW can I know for sure that the script is not accesed by 2 diferent users?
WHY: The script looks like this INSERT blablabla INTO tblClients
INSERT blablabla INTO tblProduct
INSERT idClient, idProduct, blablabla INTO tblSales
idClient and idProduct is the @@identity from thoose inserts...
the question is How do I know for sure that tblSales have the right idClient and idProduct and not from other client that other user is inserting in that percision time?
I use Application.Lock() and Application.UnLock() before and after I execute the script, but is this work?
thank you
--
Bruno Alexandre (Sintra, PORTUGAL)
@@identity is the identity of the last insert from the current sql batch.
this is thread safe, so no locking is required (unless you stick the value
into a static or vb module variable). you should look at scope_identity(),
because if a trigger inserts into a autonumber table, @@identity will be
that value. scope_identity() is the last assignment in the current scope
(will ingore trigger inserts).
-- bruce (sqlwork.com)
"Bruno Alexandre" <br********@filtrarte.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... Hi guys,
I have a web application that insert Clients info into the Database, the Apllication is accesed by several user at the same time, the Client Info is divide by 3 tables (Client, Product and 1 that combine the Client and Product and having all info for how the client bought the product)
My question is: HOW can I know for sure that the script is not accesed by 2 diferent users?
WHY: The script looks like this INSERT blablabla INTO tblClients
INSERT blablabla INTO tblProduct
INSERT idClient, idProduct, blablabla INTO tblSales
idClient and idProduct is the @@identity from thoose inserts...
the question is How do I know for sure that tblSales have the right idClient and idProduct and not from other client that other user is inserting in that percision time?
I use Application.Lock() and Application.UnLock() before and after I execute the script, but is this work?
thank you
--
Bruno Alexandre (Sintra, PORTUGAL) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mat |
last post by:
Hi,
I have a system that uploads images as BLOBs in a database. I also
have a function that I use to resize uploaded images before saving as
files. I would like to combine these two by resising...
|
by: James |
last post by:
I am in the process of running my site through WC3 validation. I
assume the validator at www.w3c.org cant accept cookies and so PHP is
attaching &PHPSESSID=lasklijasj09jsad (or similar) to my...
|
by: Miranda |
last post by:
Hi, I have a ASP/vbscript program that generates random passwords. The
problem is I need to insert those passwords into an Access database of
327 clients.
I have the random password program...
|
by: yuchang |
last post by:
Hi,
Using the FormView control is very efficient. But I want to do some
action,like showing a success message or redirect to another page, after
inserting, updating and deleting. How do I get...
|
by: Krishna |
last post by:
Hi, I have developed a for dataentry by using datagird in C# windows
application, I am using combocolumns, textbox columns for the same,
two readonly textboxcolumns for those readonly columns i...
|
by: desktop |
last post by:
Why does insert only work when specifying an iterator plus the object to
be inserted:
std::vector<intt;
std::vector<int>::iterator it;
it = t.begin();
t.insert(it,33);
If I use push_back...
|
by: gp |
last post by:
I am and have been using PDO for about a year now...and have finally
gotten around to solving the "DB NULL value" issues I ran into early
on...
I am looking for suggestions and techniques to...
|
by: Bunty |
last post by:
I want to insert values in the database.If i insert values one by one
then it works till 4 or 5 fields then after it gives error.In my
database there are more than 20 field.Pls help me.
|
by: AlexanderDeLarge |
last post by:
Hi!
I got a problem that's driving me crazy and I'm desperately in need of help.
I'll explain my scenario:
I'm doing a database driven site for a band, I got these tables for their discography...
|
by: rando1000 |
last post by:
Okay, here's my situation. I need to loop through a file, inserting records based on a number field (in order) and if the character in a certain field = "##", I need to insert a blank record.
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |