473,406 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

inserting to SQL ASP 3.0

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)
Nov 19 '05 #1
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.
Nov 19 '05 #2
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)

Nov 19 '05 #3
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)

Nov 19 '05 #4
@@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)

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
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...
3
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...
14
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...
1
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...
2
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...
12
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...
0
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...
6
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.
2
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...
5
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. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
marktang
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,...
0
jinu1996
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...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.