Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Where To Apply Locks And Cursors


Hello
I have prepared an application in VB and is installed on every system in network .The database used by me is sqlserver,can any one pls explain me where i will apply cursor and locks.how i will handle if all user try to simentaneously update same data in database.
Yogesh




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Cursors And Locks In SQL Server: Where To Put It?
Hi there!

I am writing a multi-user application using VB6, ADO and SQL-Server.
I just would like to know how to set lock options when opening database.
I know that I must to pass AdLockOptimistic, AdLockPessimistic, and so on, but I am lost and don't know WHERE I must put it!

Would like to know where to put cursor parameters too...

Thanks a lot!

Where To Apply Curosr And Locks
Hello
I have prepared an application in VB and is installed on every system in network .The database used by me is sqlserver,can any one pls explain me where i will apply cursor and locks.how i will handle if all user try to simentaneously update same data in database.
Yogesh

CAP Locks On!!!
Two queires:

1- What it is the code to know if CAPS LOCK is ON???

2- How to know IF user pressed Enter KEY ?

Thanks

COM+ && SQL Locks
Hi all,

Here are my components in the COM+ server

RootComponent - require new transaction

CompB - uses transaction.

code for CompB:

Public Sub Upd(ByVal strBankName as string,byval strCode as string)

Dim cmd As ADODB.Command
Dim conn As ADODB.Connection
Dim strSQL As String

On Error GoTo ErrorHandler

strSQL = "UPDATE bank SET " & _
"bank_nm = '" & strBankName & _
" where bank_cd = '" & strCode & "' "

' Open the connection object to the database.
Set conn = New ADODB.Connection
conn.Open connStr
conn.Execute strSQL, , adCmdText + adExecuteNoRecords

'// Cleanup
Set conn = Nothing

' Allow MTS transaction set to proceed.
MTSSetComplete

Exit Sub

ErrorHandler:

Err.Raise Err.Number, SetErrSource(modName, "Upd"), Err.Description
ReleaseObj conn, Nothing, Nothing

' Roll back
MTSSetAbort

End Sub

Question:

When I call the Upd method from the root object, the whole bank table is LOCKED.

How do I lock the updated record only, and not the whole table?.

Your inputs are much appreciated.

Tks

.NET App Locks Until Complete
I have just started using .Net and every program I create, these are beginners 101 programs, the screen seems to freeze in the program but the app is still running. The programs are not taking up much CPU. If I click on any of the buttons it seems to act as if they are not there. Takes forever to even move the program on the screen to another location, it looses screen display in the program, it all goes gray. Yet it still works but now how you would want it!

Is there some code that needs to be in the Form when it is loaded? Or is there something else in VB.NET that needs to be turned off?

Thanks

Row Locks For A Datagrid
hello,

I am using a datagrid (datagrid1). I want initial few rows of the datagrid to be non-editable and the rest to be editable. Is it possible to specify row locks for a datagrid, just as we specify column locks by the statement - datagrid1.columns(0).Locked = True.

Thanks in advance

Prashanth

Implementing Locks
Hello,

I am using SQL Server 7 and I designed a program in VB6.

I would like to know what is the best way to implement lock mechanism in vb6 on SQL server.

I've heard about SQL server and dynamic locking but I'm not aware of how to do this.

I know there is shared locks, exclusive locks, row lock, table lock, etc....

I don't know much about locks (pessimistic, optimistic, etc...) and Isolation levels (read uncomitted, read commited, etc...)

how do you specify this correctly in order to prevent loss of data on update and other erros in vb: Rs.open( ??? ).

Thanks

Mark

App Locks Up On Closing
I have a VB 6 EXE that won't shut down properly. It was working fine until I recomplied it after upgrading to XP SP2 on the machine.

I'm using an UnloadAll function that ensures all forms are closed and then shut down the last form. Not using "End" but have tried that, but makes no difference.

Not getting an error, it just locks up and increases Memory usage on the machine to 100%. Have to use CTRL-ALT-DEL to shut down program.
Happens whether shutting down in Visual Basic IDE or using the compiled EXE

Any ideas as to the cause or a fix?

Thanks in advance

File Locks
Does anyone know of any code to detect and close locks on files that are already in use (ie a remote machine has crashed, several files are left open and I want to close them so I can open them from a different machine)

Cheers

Chris

Locks In Ms-Access!!
locks in Ms-Access!!
Hi,
Can anybody tell me ,is it possible to lock a record in ms-access
at row-level/table-level?If so ,How?
Can i lock the database?If so, how?
bye,
sudhakar.

Locks In Ms-Access!!
Hi,
Is it possible to lock a record at row-level/table-level in Ms-Acceess database.

Recordset Locks
Hi All,

I just have a question about recordsets. I am using ADO control to connect to my Database.

adoConnF1.ConnectionString = "Driver={SQL Server}; " & _
"Server=FINANCIAL; " & _
"Database=finprod; " & _
"UID=sa; " & _
"PWD="

And I am using the following syntax to create a recordset..

Dim SalutationsRs as New ADODB.Recordset

strTitles = "SELECT * FROM SALUTATIONS"
SalutationsRs.Open strTitles, adoConnNAR, adOpenKeyset, adLockPessimistic, adCmdText


What I want to know is the settings for the lockedit and what each of the values do. I have here adLockPessimistic but I am not sure how that will affect others in a multi user environment.

And also what the other possible settings mean like dbLockOptimistic?

Could any provide myself with some insight or documentation on this?

Thanks
Anthony


Turn On The Cap Locks
I was wondering if it is possible to turn the caps lock on from a program

Peter

VB Recordsets And SQL Locks
HI all,

    This is my first post. Here is my question:

    I am arguing right now with another programmer on how to do the locks in VB for an SQL database. I'm not too keen on using VB's locks, since there are only 4 available (that I know of).

    We are using VB6 with sp5 with an SQL Server 2000 database.

    The way he wants to do it, is by keeping a recordset open at all times in adPessimitic mode for the lock. My point is that I do not think the recordset should be open at all times. It should only be open when you need it. I know there are situations where you might want to keep the rs open, but in this case, like browsing through participants, I do not think it is correct. As for locks I would very much like to issue my own locks to SQL through an opened Recordset.

    If I do use an opened RS with a lock in it, if the program crashes, will the lock be released?

    Many of you have probably encountered that situation. What are your thoughts on that? What do you recommend? Thanks and take care.

Marc



Edited by - mfellahi on 3/15/2004 8:49:55 AM

Records Locks
Hi All
I'm using Access DB using dao.
I have a few application accessing at the same time to the database.
This situation could generate an error.
How can i ensure all the updates will update correctly?




Edited by - shlomimo on 11/11/2003 2:52:56 AM

Locks In Recordset
hi,

I am using ado and i want to lock a record while i am updating.
My application goes like this.
Upon entering and id in a text box and if we press enter button, all the fields of that particular record will be displayed. After editing i am pressing an update button for update.
So some 4 users will be operating this.
So my requirement is i want to apply a lock which one user has already opened. So that the same record cannot be opened by another user. I want to apply a lock to the recordset.

rs.Open "select * from patents where doc_id='" & docid & "'", con, adOpenKeyset, adLockPessimistic, adCmdText

I have give the above code on text box key press event. My update statement is in another button.
So how can i apply a lock for this.
Can any one help me.

Thanks,
vinodh

LOCKS IN SQL SERVER
HI, i´m devoleped a client/server app making in vb6 using ms-sqlserver as DB. This app have many users that connect to the DB, so the problem is that many users can open at the same time the same record that is open from another user who is making UPDATES. How is the best way to check when a record is open an tell the users that these record it is been USED??? I´ve read a lot using Sp_lock or ADO LOCKS, ISOLATIONLEVEL, etc. But i think that there is a way to make this more easy. I Hope this little explanation makes more visible where is the problem. Sorry for my bad english.

MMCONTROL Locks Up
Anyone know of a problem with MMCONTROL where the thing occasionally locks up? And by locking up I mean not only my VB code doesn't produce sound but neither does SoundRecorder from the Start/Programs/Accessories/Entertainment menu. When this happens the only solution I know of is to shutdown & cycle power to the PC. Anyone know of a fix?

Here's my code:

MMControl.Command = "Close"
MMControl.FileName = FXfile
MMControl.Command = "Open"
MMControl.Command = "Prev"
MMControl.Command = "Play"

I use MMControl_Done to know when it's ok to use it again.

When I close out VB I also do...

MMControl.Command = "Close"

It might be PC or Windows related... I'm on a NetVista with Windows-2000. It seems to only lock up when I end my VB program and start it up again.

Help With Cursors
I wanted to make a colorful animated cursor for my program but I don't know how. I tried to change the mouseicon attribute but the cursor becomes black and white and they don't support .ani

What can I do?

Cursors
can i get some help with cursors, in vb i cant get color to show, can some1 help me?

Cursors
I was wondering if anyone knows the code to make a cursor blink in like a text box of something to let the user know that its ready to type.

Cursors
Ok ive made an animated cursor and i was wondering how would i use it on my project??

Cursors
Mh.. my 256 color cursor works fine in windows, I tested it, but when I try to use it in a VB app.. its black and white! !! Any ideas?

ADO Cursors
Further to my other posts, the other thing i am having a small problem with is Cursors, i have a first and next button on my form, but if i try and put a Last it comes up with cannot do as i have no backward cursor, what is the correct cursor type to put on, ,adLockdynamic, static and optimistic don't work??

Cursors
I have made a cursor 'theme' and I would like to be able to distribute it, by creating a program that would give a preview of this and other themes I will make, then the user can use the themes by clicking ONE button.

How would I go about setting the computer to use my cursors? (ie. like going into settings / mouse / pointers and manually setting them, only automatic)

hope that makes sense.
thanks!

cent1pede@hotmail.com

çentipede
http://mp3.com/orguss

Cursors
Where can I find professional cursor files (.cur files) I'm busy with a drag and drop program and the drag and drop cursor I have is way to big. I don't want any fancy animated memory hogs, just a simple sleek looking cursor.

Any help is appreciated

Thanks

Chris

Cursors
i would like my picture boxes and labels to act like hyperlinks, so it has the hand icon when i move the mouse over it. i have noticed that you cant use the mouse drag because you cant click

Cursors
Can someone show me a code of example using Cursors looping through the result of a select inside a stored proc?

thanks

Cursors
Other than using the 99-Custom to change to a specific mouse pointer is there another way via code????

Cursors
How would I specify on a form using VB which mouse icon I would like to use???? (by filename as opposed to:

screen.mousepointer = vbHourGlass (etc.)

Cursors!??
I want to use an animated cusor to show the user that the application is still running . (like the animated sand glass cursor in windows)

Cursors In VB.NET
Hello,

I am setting the cursor as "Help" from an MDI form. The cursor remains as
the "Help" icon over the mdi childs but it changes back to default when it
hovers over some COM components (older ActiveX's - not dot net components).

Does anyone know how to solve this?

Best regards
Darren Logan BSc(Hons)
Development Engineer

Help Regarding Ado Cursors...
Hi,

I am working on a ten user system on win2000 server.

i am developing a workflow system in vb6 and with access2000 as the backend.

Can anybody please suggest the cursor location, cursortype, locktype to use.

the users will be logged on to the database continuously and one of the listboxes on one of the forms should continuously keep refreshing the list and the changes should be reflected back on every user's screen. I am using a timer control which extracts a fresh recordset after every three secs.

thank you

Ashish Kamat

Cursors
Hi,

How can I use the Hand cursor (the one that internet explorer uses when hovering over links) when i hover over buttons and images? I know I can change the cursors within the form, but the hand cursor isn't there?

Is this possible?

Thanks/...

Error 75 - Locks Files
I am getting an error 75, I believe because the program is locking up files... I make this assumption because I can’t even delete the file from explorer... Is there a way to close connections with files? Here is the code I am getting stuck on.. Thanks in advance if anyone has any idea's

P/S This code is just deleting all files/directories within a given Directory... If anyone know of a better way please let me know....

THIS IS THE CODE THAT IS CRASHING THE POGRAM


Code:
While intCt >= 0
Debug.Print intCt
Debug.Print strDirDel(intCt)
RmDir (strDirDel(intCt) & "")
intCt = intCt - 1
Wend

Here is all the Code


Code:
Private Sub Command1_Click()
DoEvents
startDir = "D:ORIG2"

Dim s As String
Dim currdir As String
Dim dirlist As New Collection
Dim fn As String
Dim strDirDel() As String
Dim intCt As Integer

DoEvents
intCt = 0
ReDim strFile(intFileCt)
DoEvents

If Right$(startDir, 1) <> "" Then startDir = startDir & ""
dirlist.Add startDir
While dirlist.Count
currdir = dirlist.Item(1)
dirlist.Remove 1
s = Dir$(currdir, vbDirectory)
While Len(s)
If (s <> ".") And (s <> "..") Then
If GetAttr(currdir & s) = vbDirectory Then
dirlist.Add currdir & s & ""
ReDim Preserve strDirDel(intCt)
strDirDel(intCt) = currdir & s & ""
intCt = intCt + 1
End If
End If
s = Dir$
Wend
Wend
DoEvents

For intTemp = 0 To intCt - 1
If Dir$(strDirDel(intTemp)) <> "" Then
Kill strDirDel(intTemp) & "*.*"
End If
Next intTemp
DoEvents

Debug.Print intCt

intCt = intCt - 1
While intCt >= 0
Debug.Print intCt
Debug.Print strDirDel(intCt)
RmDir (strDirDel(intCt) & "")
intCt = intCt - 1
Wend

Kill startDir & "*.*"
End Sub

CommonDialog Locks Folder
I use CommonDialog to open a file. After the dialog box closes I cannot delete/rename the folder I was opening the file from unless I close the application. It looks like the Common Dialog control is locking the folder. "It is being used by another person or program." (in Windows Explorer) or "Permission denied" (in application).
How can I release the folder so I can delete it?

Thanks.

Winsock Control Locks Up VB 6.0 App
I have a Winsock Control that listens on my local port for a message. When the "ConnectionRequest" subroutine is activated, the Winsock Control closes, a message is sent back stating that the original message was received, and the "DataArrival" subroutine is automatically called. Then, a subroutine is called that does some processing based on the message received, and a confirmation message is sent back. Everything seems to be working fine except for the fact that when I attempt to close the Winsock Control and "End" the VB 6.0 application, my app becomes locked up. I have to kill it manually. What am I doing wrong? Here is the code I'm using to close it:

If Winsock1.State <> sckClosed Then
Winsock1.Close
DoEvents
End If
End

Thanks in advance for your help.

Mmtask Locks The Computer
Hi!

I'm doing an ap. which receiving data by the serial port (ascii) from a machine (1200 baud).

Somtime the ap. locks the computer - or - somtime when we turn the computer of we recieve an error "Mmtask error" and it seems to be in the run32dll file. ctrl-alt-del and then turning of run32dll will help.

Private Sub Form_Load()
MSComm1.CommPort = GetSetting("ComPro", "settings", "comport")
MSComm1.Settings = "1200,n,8,1"
MSComm1.RThreshold = 1

MSComm1.RTSEnable = True
MSComm1.InBufferSize = 0
sBuffer = " " '(need some space)
If (MSComm1.PortOpen = False) Then
MSComm1.PortOpen = True
End If
End Sub

Private Sub MSComm1_OnComm()
If MSComm1.CommEvent = comEvReceive Then
Timer1.Enabled = True
start = Now
lblMess.Caption = "Receiving data...."
sBuffer = sBuffer & MSComm1.Input
txtContent.text = sBuffer
End If

End Sub

Do I have to clear the inputbuffer or something after I recieved the data? The computer is a old laptop (PII 450) with win 98.

AddPicture Locks File
I am automating the insertion of images into the doc I am working on. I use the AddPicture method. However, when I have added the picture, the file that was loaded is locked and cannot be deleted. How do I overcome this problem without having to reload/restart Word or the document?

Thanks

Visual Basic Just Locks Up...
everytime i hit the end button/close my program window vb just stops responding


which means each time i test somthing, i have to save it before i run it, then reload vb.

Anyidea what could cause this, it happens on my 900mhz, and my 2.8ghz

I have a feeling it's somthing with winsock/ports maybe?

DO LOOP Locks Up System
I have been programming in QuickBasic for god knows how long and just recently moved up to VB6, so I know how to program pretty well, just in QB. Well, this is my problem:

I am writing a program that takes a text file, parses needed information out of it, and places it in a database. This database can be managed by several subs, all including quit lengthy Do Loops. There are currantly 7,583 records in the database. When in these do loops the program places the entire system on a hold, not freezing it, but somehow disables the multitasking cababilities of windows, it also does not redraw the forms, unless told to do so, but I think this is normal. So, is there a method or command that will enable the system to go elsewhere and run other programs?

Thanks

Program Locks When Using Variants
Hi,

I have made a program which enter part numbers one at a time to a terminal. To do this the user has to copy the part numbers he wants to enter from for example excel. The code below takes the data in the clipboard and put it into a variant, then I use the split function and a for loop to get all the part numbers one at a time. However, I have found that when you copy more than (about) 32 000 part numbers in the clipboard and try to do the procedure below, the program freezes with a constant cpu use of about 95 %.

Can anyone see the error here and help me? Is the variant type not good enough for a big amount of data??

Regards
Harry


Code:
Dim list, list2, list3 As Variant
Dim counter As Integer
Dim Upprepningar, stringlength As Integer

Data = Clipboard.GetText
list = Split(Data, Chr$(10)) 'Split after every enter
Upprepningar = UBound(list)

For counter = 0 To Upprepningar
list2 = Split(list(counter), Chr$(13)) 'removes square sign
list3 = Split(list2(0), Chr$(9))
artikelnummer = list3(0)
....

Access Record Locks
I have an Access97 database (data.mdb) on a server functioning as a backend. I went to the server this morning and to check the files in-use and noticed that each user (approx 10) accessing this back-end had 70+ record locks on the data.ldb file.

Why does each user have so many locks? Is this a thing of concern?

A Project Involving ADO And Locks...
Hi everyone,

I have a problem I can't seem to get a grip on. Let me go through the project and how it works..

Documents are indexed. These index values are stored in a database first before writing them to the main System. The fields of this database are ID, InvoiceNumber, LineNumber and Date.

When I write to this database, I first get the last record and store the ID, I add 1 to the ID and write out the record.

Here is my problem, a few people use the software. If they happen to hit hte same code athe same time, I get an error because they are trying to use the same ID which is a primary key.

So, I changed the lock type to LockOptimistic. This brings 2 questions.

1. What will happen when the program tries to open the recordset but it is locked..

2. Am I doing this a totaly bogus way?

Any input would be great.

Thanks in advance.

-- Wrong? The perception of what others think is right, does not mean its wrong --

Access Locks Not Working.
Hi.

I have a multi-user application in VB6, using Access to store my the data. I have an update transaction, and I would like to restrict updates to 1 user per update, meaning, a certain file can only be used by a single user when the file is being updated.

I tried using the locktype = pessimistic properties for my ADODC (setting it to 2 in the properties window and specifying it by code when the a command button is clicked) but it doesn't work. it doesn't even give me any error-message that i can trap. it just allows all users to have access to the same date all of the time.

I'm using Access 2K, BTW. WinXP OS.

Thanks.

Recordset And Locks For Multiuser
I m working on multiuser software(biling)
i m having 3 tables in sql 6.5 1.Master n 2 Details and counters
in master details im saving transaction and in counters i m keeping counter like voucher No for transactions when the user saves a record i increase a voucher no by 1 from counters and update that table counters by current voucher no but when at the same time if 2 user r saving in the same table both r getting the same voucher no and one is getting saved and nother is getting error for duplicate how should i open recordsets and locks so that both sould work smooth or wht is other way for such type of work

VB6 IDE Bug: Locks Form Size
Has anyone seen this bug??
In VB6 sp5 IDE:
Sometimes a form's (or lots of forms) size is locked down to 3/4 screen width. It cannot be resized by the forms right Vertical bar or arrows keys.
Even worse it cannot be sized at runtime with .Width or .Move !!!!
The bug has been there since VB5, vb6 sp3...5 and seems to occur randomly about once a week.
I suspect it happens after resizing the properties box??


The only cure I have found is to quit VB and reload it, and manually resize the forms.
The bug is a big pain, as I have to check every form before distributing a program....

My Code Locks Up The Program
Can anyone tell me how to fix this code? Everytime i click the command button it locks VB. If I take a couple of 0's of the end to lower the value of the numbers and causing it not to have to count so high it works fine.

Private Sub Command1_Click()
Dim count As String
Do While count < 50000000
If count = 10000000 Then
Print "10"
ElseIf count = 20000000 Then
Print "20"
ElseIf count = 30000000 Then
Print "30"
ElseIf count = 40000000 Then
Print "40"
ElseIf count = 50000000 Then
Print "50"
End If

count = count + 1
Loop
End Sub

How Do I Release All Locks On Access DB From VB
After I exit my application which is a VB5 program exe file linked to an MSAccess Database, I try to delete the exe program file in NT Explorer and it tells me permission denied. It seems as if it is still linked in some way to the mdb file even when the program isn't running. I need to remove this link any ideas. Please help.

Copyright © 2005-08 www.BigResource.com, All rights reserved