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

Issues with access database locking in VB windows app

Hi All,

I am having an issue with an windows application made from VB.NET 2003 which is using an access database.
Basically the problem is that when the user updates a field on the app from a drop down, it tries to update the access db. This causes the db to lock itself and not allow anyother updates.

What I would like to do is be able to update just the in memory datatable for each field then use an update button to update everything at once, hopefully getting around access's locking issues.

This is a sample of the code that is being used sofar.

Private Sub UpdateMark(ByVal lStudentIDToUpdate As Int32, ByVal lNewMarkIDToStore As Int32)

Dim oConnection As OleDbConnection
Dim oCommand As OleDbCommand
Dim oRows() As DataRow
Dim oRow As DataRow
Dim lTeacherCourseIDToUpdate As Int32

Try

oRows = oStudentMarks.Select("StudentID=" & lStudentIDToUpdate)
oRow = oRows(0)
lTeacherCourseIDToUpdate = oRow("TeacherCourseID")

sConnectionString = ConfigurationSettings.AppSettings("ConnectionStrin g")

oConnection = New OleDbConnection(sConnectionString)
oConnection.Open()

oCommand = New OleDbCommand
oCommand.Connection = oConnection
oCommand.CommandType = CommandType.Text

oCommand.CommandText = "UPDATE StudentCourseMap SET MarkID=" & lNewMarkIDToStore.ToString & " WHERE StudentID=" & lStudentIDToUpdate.ToString & " AND TeacherCourseID=" & lTeacherCourseIDToUpdate
oCommand.ExecuteNonQuery()

bFirstDataLoadComplete = False
LoadStudentMarks(lCourseID, lTeacherID)
bFirstDataLoadComplete = True
lstClassList.SelectedValue = lStudentIDToUpdate

Catch ex As Exception

'MsgBox("Unfortunately Error:[" & ex.Message & "] has occured. Please close the form and try relaunching", MsgBoxStyle.OKOnly, "Unrecoverable Error")

Finally

If Not (oConnection Is Nothing) Then
oConnection.Close()
End If

End Try

End Sub
Private Sub BindMarksList()

cbxMarks.DataSource = oMarks
cbxMarks.DisplayMember = "Prompt"
cbxMarks.ValueMember = "MarkID"
lMarkID = cbxMarks.SelectedValue

End Sub

Private Sub cbxCourses_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbxCourses.SelectedIndexChanged

If bFirstDataLoadComplete Then

lCourseID = cbxCourses.SelectedValue
LoadStudentMarks(lCourseID, lTeacherID)

End If

End Sub

The user has to update 3 fields per student and can have up to 25 students.

Tks for any and all help.

Taz
May 22 '07 #1
1 1424
Dököll
2,364 Expert 2GB
Hi All,

I am having an issue with an windows application made from VB.NET 2003 which is using an access database.
Basically the problem is that when the user updates a field on the app from a drop down, it tries to update the access db. This causes the db to lock itself and not allow anyother updates.

What I would like to do is be able to update just the in memory datatable for each field then use an update button to update everything at once, hopefully getting around access's locking issues.

This is a sample of the code that is being used sofar.
Expand|Select|Wrap|Line Numbers
  1. Private Sub UpdateMark(ByVal lStudentIDToUpdate As Int32, ByVal lNewMarkIDToStore As Int32)
  2.  
  3.         Dim oConnection As OleDbConnection
  4.         Dim oCommand As OleDbCommand
  5.         Dim oRows() As DataRow
  6.         Dim oRow As DataRow
  7.         Dim lTeacherCourseIDToUpdate As Int32
  8.  
  9.         Try
  10.  
  11.             oRows = oStudentMarks.Select("StudentID=" & lStudentIDToUpdate)
  12.             oRow = oRows(0)
  13.             lTeacherCourseIDToUpdate = oRow("TeacherCourseID")
  14.  
  15.             sConnectionString = ConfigurationSettings.AppSettings("ConnectionString")
  16.  
  17.             oConnection = New OleDbConnection(sConnectionString)
  18.             oConnection.Open()
  19.  
  20.             oCommand = New OleDbCommand
  21.             oCommand.Connection = oConnection
  22.             oCommand.CommandType = CommandType.Text
  23.  
  24.             oCommand.CommandText = "UPDATE StudentCourseMap SET MarkID=" & lNewMarkIDToStore.ToString & " WHERE StudentID=" & lStudentIDToUpdate.ToString & " AND TeacherCourseID=" & lTeacherCourseIDToUpdate
  25.             oCommand.ExecuteNonQuery()
  26.  
  27.             bFirstDataLoadComplete = False
  28.             LoadStudentMarks(lCourseID, lTeacherID)
  29.             bFirstDataLoadComplete = True
  30.             lstClassList.SelectedValue = lStudentIDToUpdate
  31.  
  32.         Catch ex As Exception
  33.  
  34.             'MsgBox("Unfortunately Error:[" & ex.Message & "] has occured.  Please close the form and try relaunching", MsgBoxStyle.OKOnly, "Unrecoverable Error")
  35.  
  36.         Finally
  37.  
  38.             If Not (oConnection Is Nothing) Then
  39.                 oConnection.Close()
  40.             End If
  41.  
  42.         End Try
  43.  
  44.     End Sub
  45. Private Sub BindMarksList()
  46.  
  47.     cbxMarks.DataSource = oMarks
  48.     cbxMarks.DisplayMember = "Prompt"
  49.     cbxMarks.ValueMember = "MarkID"
  50.     lMarkID = cbxMarks.SelectedValue
  51.  
  52.   End Sub
  53.  
  54. Private Sub cbxCourses_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbxCourses.SelectedIndexChanged
  55.  
  56.     If bFirstDataLoadComplete Then
  57.  
  58.       lCourseID = cbxCourses.SelectedValue
  59.       LoadStudentMarks(lCourseID, lTeacherID)
  60.  
  61.     End If
  62.  
  63.   End Sub
  64.  
  65.  
The user has to update 3 fields per student and can have up to 25 students.

Tks for any and all help.

Taz
A desperate attempt to gain you some hits, tazdiver :-)
Jun 2 '07 #2

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

Similar topics

1
by: intl04 | last post by:
Are there any problems with multiple user access to the same Access database on a shared network drive? I have 'shared' chosen for 'default open mode'. As for the record locking properties, I...
3
by: Leinad Kong | last post by:
I'm using Access 2002, as front-end and back-end as well: 1) I faced database corrupted problems, when more than 1 user edit concurrently. I'm using All-records Locking, and open-exclusively as...
16
by: Rob Geraghty | last post by:
I've just spent some time looking through FAQ sites and searching the google archives of this newsgroup, but I still haven't been able to find a clear explanation of an issue with multi-user...
6
by: mark | last post by:
I have an asp.net ecommerce web application on a remote web server. I'm using an Access database on the back end. I've notice a few strange things. When I mimic an multiple user environment by...
4
by: James | last post by:
I have a VB windows forms application that accesses a Microsoft Access database that has been secured using user-level security. The application is being deployed using No-Touch deployment. The...
1
by: Bob Alston | last post by:
Having problems sharing an Access database on a Windows 2000 PC. The other PC is windows 98 (as I recall) but NOT windows 2000! The 2nd PC has a shortcut to the MDB on the primary PC. The MDB...
2
by: Frav | last post by:
The Reps team have been experiencing that Access 2002 unexpectedly quits while working and also lots of Corruption Failures and "Record lock can not update" messages since the upgrade from...
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...
6
by: stuart | last post by:
I have 2 users who ran into a problem with a data entry program (written in Access 2003). One user was keying into one of the forms when she got the message "ACCESS Error Number: 3218 Could not...
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
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.