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

Can MSSQL do what foxpro did in terms of record locking?

Can MSSQL do what foxpro did in terms of record locking? if so? How?. Tnx
Mar 8 '13 #1
7 1763
Rabbit
12,516 Expert Mod 8TB
Since this is the Microsoft SQL Server forum, you can't expect us to know what foxpro did in terms of record locking. You will have to tell us what it did and we can tell you if there's similar functionality.

You should be aware though that foxpro is more like Microsoft Access, combining a database engine with a front end interface. Whereas Microsoft SQL Server is just the database engine.

Therefore, if what you want to accomplish is a front end issue, that is not something that Microsoft SQL Server can accomplish.
Mar 8 '13 #2
Sir, I am just concert with the data i currently working with hundreds of table.
What I want to do is to avoid duplication and handles those error.
in foxpro simply,


Expand|Select|Wrap|Line Numbers
  1. FUNCTION get_referenceNo()
  2. DO WHILE .t.
  3.     nLAstno = 1
  4.     SELECT tbl_setup
  5.     SET ORDER TO tag intcode
  6.     IF SEEK('001')
  7.         DO WHILE .t.
  8.             IF RLOCK()
  9.                 nLastno = tbl_setup.lastno
  10.                 REPLACE tbl_setup.lastno WITH nLastno + 1
  11.                 UNLOCK 
  12.                 EXIT 
  13.             ENDIF 
  14.         ENDDO 
  15.     ENDIF 
  16.     SELECT tbl_itinerary
  17.     SET ORDER TO tag itineraryno
  18.     IF !SEEK(nLAstno)
  19.         EXIT 
  20.     ENDIF 
  21. ENDDO 
  22. RETURN nLAstno
  23. ENDFUNC 
  24.  
  25.  
  26. USing MSSQL I got this
  27.  
  28.  
  29. Dim rs As New ADODB.Recordset
  30. Dim cn As New ADODB.Connection
  31.  
  32. Private Sub Form_Load()
  33. cn.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=SubReceiving;Data Source=.\SQLEXPRESS"
  34. End Sub
  35. Function get_referenceNo()
  36. Do While True
  37.     Set rs = Nothing
  38.     rs.Open "select lastno from tbl_setup where intcode='001'", cn, adOpenStatic
  39.     nLastno = 1
  40.     If rs.RecordCount > 0 Then
  41.         nLastno = rs.Fields("lastno")
  42.         cn.Execute "update tbl_setup set lastno=" & nLastno + 1 & ""
  43.     End If
  44.     Set rs = Nothing
  45.     rs.Open "select * from TBL_ITINERARY where ITINERARYNO=" & nLastno & "", cn, adOpenStatic
  46.     If rs.RecordCount = 0 Then
  47.         Exit Do
  48.     End If
  49. Loop
  50. get_referenceNo = nLastno
  51. End Function
  52.  
But it is not Invincible, maybe there is other solution to do it in SQl
if i were maybe lock those record, I will add another loop so other workstation will block untill the one who lock the record
releases.

I badly need suggestion..tnx
Mar 9 '13 #3
Rabbit
12,516 Expert Mod 8TB
Again, this is the Microsoft SQL Server forum. I don't know FoxPro code so I can't tell you whether or not you can duplicate what you're doing in the code. You will need to describe what you want to do in words, not code.
Mar 10 '13 #4
Ok Sir, I heard that MSSQL has record locking capabilies.
My questions are:
1. How to lock and unlock records?
2. How to determine which rows are locked?
Mar 12 '13 #5
Rabbit
12,516 Expert Mod 8TB
Locking is mostly done automatically but you can use the HOLDLOCK and ROWLOCK hints to force and hold a lock until your transaction is committed.

The sys.dm_tran_locks procedure will tell you about currently active requests to the lock manager for a lock that has been granted or is waiting to be granted.
Mar 12 '13 #6
One thing, how can We determine which rows are locked?
Mar 14 '13 #7
Rabbit
12,516 Expert Mod 8TB
You can use the READPAST hint to return those unique ids that have no locks. The complement of those ids will be the locked records. You will need to use the NOLOCK hint to return those records.
Mar 14 '13 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Ryan | last post by:
I have a problem with record locking / blocking within an application. The app is quite straight forward. Written in Delphi 5 using BDE to access a SQL 7 database (Win2K server). Every so often...
1
by: Justin | last post by:
Hello: I have a question regarding Record Locking in ASP...If the user x's out of the web page, how can I unlock the record? A co-worker told me it has to be done in Javascript, but he doesn't...
0
by: Megan | last post by:
Hi- I have a question about the Microsoft Access Record-Locking Information Icon. Whenever I, or my friends, open my MS Access database, the Microsoft Access Record-Locking Information Icon...
0
by: ethanj /personal/ | last post by:
We are using Access 2000 database, with the following settings. Tool > Options > Advance > Default Record Locking = Edited Record Open databases using record level locking = True Form...
1
by: Simon | last post by:
Dear reader, In case I work with two Forms and using the same Table but with other fields in the Forms, I have the following experience. After I change in one of the two Forms a field I can't...
0
by: swapna_munukoti | last post by:
Hi all, I have seen in so many articles that record locking is not possible in MS-Access, but we can achieve it by making the size of each record to 1024 bytes(Let us say this is the record...
5
by: swapna_munukoti | last post by:
Hi all, Is there any tool to achieve record locking in MS Access 2000. Thanks, Swapna.
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...
0
by: Cindy Huyser | last post by:
I have an Access 2000 database behind a threaded Java application that that can have have concurrent access to the same table (but not the same record). The database is set up for shared access...
3
by: kstevens | last post by:
I have turned on record locking do to the fact that we are starting to have issues with the records not being locked. I have a button on a form that changes the recordsource of the form. When i...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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...

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.