we are getting this error when we try to write to an access database. "Could not save; currently locked by user 'Admin'..."
We are trying to insert a new row.
Prior to inserting the new row we have used this code to read the database. What can we do to unlock the table/row so we can write to it? Or is there a better way to read it? Thanks!
Dim oDataAdapter As OleDb.OleDbDataAdapter
Dim oDataset As New DataSet
Dim sSQL As String
Try
sSQL = "SELECT * FROM Reminder WHERE LogonID = '" & sLogonID & "'"
If bActiveOnly Then
sSQL = sSQL & " AND ActivationDateTime <= #" & Now & "# AND IsDismissed <> True "
End If
sSQL = sSQL & "ORDER BY ReminderID"
oDataAdapter = New OleDb.OleDbDataAdapter(sSQL, ConnConfigDB.GetTEAMConnectionString)
oDataAdapter.Fill(oDataset)
DBGetRemindersByLogonID = oDataset.Tables(0).Copy
oDataset.Dispose()
oDataAdapter.Dispose()
Catch e As System.Exception
ExceptionManager.Publish(e)
MsgBox("Error occurred in procedure DBGetRemindersByLogonID. The error is '" & e.ToString)
Comments
: We are trying to insert a new row.
: Prior to inserting the new row we have used this code to read the database. What can we do to unlock the table/row so we can write to it? Or is there a better way to read it? Thanks!
:
: Dim oDataAdapter As OleDb.OleDbDataAdapter
: Dim oDataset As New DataSet
: Dim sSQL As String
:
: Try
: sSQL = "SELECT * FROM Reminder WHERE LogonID = '" & sLogonID & "'"
: If bActiveOnly Then
: sSQL = sSQL & " AND ActivationDateTime <= #" & Now & "# AND IsDismissed <> True "
: End If
: sSQL = sSQL & "ORDER BY ReminderID"
: oDataAdapter = New OleDb.OleDbDataAdapter(sSQL, ConnConfigDB.GetTEAMConnectionString)
: oDataAdapter.Fill(oDataset)
: DBGetRemindersByLogonID = oDataset.Tables(0).Copy
: oDataset.Dispose()
: oDataAdapter.Dispose()
:
: Catch e As System.Exception
: ExceptionManager.Publish(e)
: MsgBox("Error occurred in procedure DBGetRemindersByLogonID. The error is '" & e.ToString)
:
:
:
Hi,
I'm not sure about this, try closing the connection before you insert
the new record.
// Patrik