473,387 Members | 1,678 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,387 software developers and data experts.

creating a record lock to ensure that only one user is updating records at a time

Help!
I have created an application using vb 6 that allows users (5) to create
orders by connecting to s sql database.
The only problem is that to often I am getting duplicate order numbers.

Here is the code:

adopagecounter.Open "select id,pagecounter,pagedate from Mops_counter",
db, adOpenDynamic, adLockOptimistic
dateformat = Format(adopagecounter.Fields("pagedate"), "ddddd")
If dateformat <> dateformat2 Then adopagecounter.Fields("pagedate") =
dateformat2: adopagecounter.Fields("pagecounter") = 1
mopscounter = adopagecounter.Fields("pagecounter")
adopagecounter.Fields("pagecounter") = mopscounter + 1
adopagecounter.Update
adopagecounter.UpdateBatch
adopagecounter.Close

I open the record set to get the next number
I then test the date of the record against the system date
If they do not match then the record counter is reset to one and the
date is reset to the system date.
I then make a variable equal to the pagecounter
After that I add one to the pagecounter and update the recordset and
then close it.

Through all of this something is left open and often times I get two of
the same order numbers.
I am at a loss of how this happens.
I would appreciate any ones input about this problem.
Thank You,
VBGEEK


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #1
1 1637
Use an SQL trigger to do the creation of the order number.

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
rmvbgeek wrote:
Help!
I have created an application using vb 6 that allows users (5) to create
orders by connecting to s sql database.
The only problem is that to often I am getting duplicate order numbers.

Here is the code:

adopagecounter.Open "select id,pagecounter,pagedate from Mops_counter",
db, adOpenDynamic, adLockOptimistic
dateformat = Format(adopagecounter.Fields("pagedate"), "ddddd")
If dateformat <> dateformat2 Then adopagecounter.Fields("pagedate") =
dateformat2: adopagecounter.Fields("pagecounter") = 1
mopscounter = adopagecounter.Fields("pagecounter")
adopagecounter.Fields("pagecounter") = mopscounter + 1
adopagecounter.Update
adopagecounter.UpdateBatch
adopagecounter.Close

I open the record set to get the next number
I then test the date of the record against the system date
If they do not match then the record counter is reset to one and the
date is reset to the system date.
I then make a variable equal to the pagecounter
After that I add one to the pagecounter and update the recordset and
then close it.

Through all of this something is left open and often times I get two of
the same order numbers.
I am at a loss of how this happens.
I would appreciate any ones input about this problem.
Thank You,
VBGEEK


Nov 13 '05 #2

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

Similar topics

31
by: Neil | last post by:
I have an Access 2000 MDB with ODBC linked tables to a SQL Server 7 back end. I currently have a selections table in the front end file which the users use to make selections of records. The table...
5
by: Ross A. Finlayson | last post by:
Hi, I'm scratching together an Access database. The development box is Office 95, the deployment box Office 2003. So anyways I am griping about forms and global variables. Say for example...
7
by: Susan Bricker | last post by:
Greetings. As a relative newcomer to Access, I am having trouble deciding on how to design the form flow for updating and creating related records. I'm looking for a variety of suggestions so...
22
by: RayPower | last post by:
I'm having problem with using DAO recordset to append record into a table and subsequent code to update other tables in a transaction. The MDB is Access 2000 with the latest service pack of JET 4....
19
by: rich | last post by:
I am building an app using php and postgresql. My questionis this. How do you handle people wanting to make parallel changes to a record. Since in web apps you are doing a select, bring over a...
0
by: Murali | last post by:
In MsAccess project I Create the Link table with Sqlserver 2000. I am facing the multiuser Problem in my application. The problem describes below: If one user is updating one record and at that...
9
by: master | last post by:
Actually, it is not only the record locking, what I need, and nobody seems to descibe this. Imagine the following scenario. There is a database with, say 10000 records with some unvalidated...
1
by: =?Utf-8?B?UiBSZXllcw==?= | last post by:
Hi, I'm having an issue in my C#.NET desktop application where two or more people viewing/editing the same record (from SQL Server) keep overwriting each others changes. Is there a setting in...
19
by: emanning | last post by:
Using Access 2003 and using a form that's mostly bound. I need a way to tell if user-1 is on the record when user-2 tries to open the same record, w/o waiting for the user-1 to save the record...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.