Click here to Skip to main content
15,888,022 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi.. i am using VB.net code and access DB. In my application i am doing some major table structure level changes through vb.net code. while doing this i am getting error
File sharing lock count exceeded. Increase MaxLocksPerFile registry entry

Access DB file version is 2000.
using vb.net(desktop application), vs10, access

What I have tried:

I have gone through this[^]
but i cannot do this activity at all end user's PC. So please help me to solve this at code level.

sample code
sSql = "ALTER TABLE tblTimeRegister ALTER COLUMN STATUS longtext"
            If Common.con1.State <> ConnectionState.Open Then
                Common.con1.Open()
            End If
            Dim cmd As OleDbCommand
            cmd = New OleDbCommand(sSql, Common.con1)            
            cmd.ExecuteNonQuery()

            If Common.con1.State <> ConnectionState.Closed Then
                Common.con1.Close()
            End If

note: this is just a one part of code... there are so many ADD COLUMN and ALTER COLUMN
Posted
Updated 19-Jul-19 20:01pm
v2

1 solution

At a guess - and that's all it can be, we don't have access to your full code, or to your DB - you've opened so many Commands and so forth that you have exceeded the systems lock count, possibly combined with accessing the same Access file from too many users simultaneously.

To fix the former, use Using blocks around your Command constructors to automatically Close and Dispose them when you are finished.
To fix the latter, don't use Access as a multi-user database, it always gives problems which are a PITA to fix.
 
Share this answer
 
Comments
Nitin Surya 20-Jul-19 2:37am    
which resourceType will work for this?
OriginalGriff 20-Jul-19 3:13am    
None. Why?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900