Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Locking VFP records in ASP.NET
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01348296
Message ID:
01348328
Views:
15
Hi Greg,

You might wish to consider using a common "semaphore" flag or file (or maybe a cookie). Write a method that sets the flag true (or stores the file in a known location) IF IT'S FALSE OR NONEXISTENT, retrieves the ID, then sets the flag false or deletes the file when it has the desired ID. If somebody else happens to call the method while it's in use, they see the flag as true or the existence of the file -- which tells them that somebody else is getting one of those IDs at that moment. The second user can then either delay momentarily and try again, or return a "sorry, couldn't get an ID for that key right now" to the app. It's not an elegant solution, but it works.

It may also mean that you occasionally have to have something in place to clear the flag(s) or delete the file(s) just in case the app died prematurely the last time, but that's a small price to pay.

HTH.

>We have an ASP.NET application that writes records into Visual Foxpro tables. We use an "ID" table that has a record for every table for the purposes of assigning the next primary key for a given table. Previous we used code much like:
>
>
>
>lnNextid = 0 
>LOCATE FOR id.tablename = lcTable
>IF !EOF()
>     if RLOCK()
>        lnNextid = id.keyvalue
>        replace id.keyvalue with lnnextid + 1
>    endif
>endif
>return lnNextid
>
>
>The problem is in ASP.NET with ODBC connection we have no way of locking the record (that i know of) to make sure two users do not happen to similtaneously call our newid function and receive a duplicate key.
>
>What would be the best way of grabbing and updating these primary keys from an ASP.NET application?
>
>Thanks in advance!!!
Evan Pauley, MCP
Positronic Technology Systems LLC
Knoxville, TN

If a vegetarian eats vegetables, what does a humanitarian eat?
Previous
Reply
Map
View

Click here to load this message in the networking platform