Im trying to create a system service that will read some records within an
access file. From these values I will then be able to see if other software
in the system is up to date and install the new versions if they are not.
The problem im running into is that I can't get a connection to the file.
I keep on getting the error "The Microsoft Jet database engine cannot open
the file 'c:\DatabasesInfo.mdb'. It is already opened exclusively by another
user, or you need permission to view its data."
Now I know that the file is not opened up by anyone else so that must mean
that I don't have permission to use it.
Unfortunately I have no idea how I'm supose to give myself permission to use
it. Does anyone know how I can do that or if it's not that then what is it
that i'm doing wrong?
Here is the code that I use to open it.
Private Function ConnectionString() As String
Dim cnx As String = "Provider=Microsoft.Jet.OLEDB.4.0;Password=;Us er
ID=Admin;Data Source={0};Mode=ReadWrite|Share Deny None;;Jet OLEDB:Engine
Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk
Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database
Password=;Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt
Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet
OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False"
Dim path As String = "c:\DatabasesInfo.mdb"
Return String.Format(cnx, path)
End Function
Private Function KitsAndTraysVersion() As String
EventLog1.WriteEntry("Starting Database Connection",
EventLogEntryType.Information)
Dim connection As New System.Data.OleDb.OleDbConnection(ConnectionString )
Dim output As String
Try
'Open Database Connection
connection.Open()
EventLog1.WriteEntry("Finished Database Connection",
EventLogEntryType.Information)
Dim command As New System.Data.OleDb.OleDbCommand(String.Empty, connection)
Dim reader As System.Data.OleDb.OleDbDataReader
command.CommandText = String.Format("select Version from Databases")
reader = command.ExecuteReader(CommandBehavior.Default)
While reader.Read
EventLog1.WriteEntry(reader("Version"), EventLogEntryType.Information)
End While
reader.Close()
Catch ex As Exception
EventLog1.WriteEntry(ex.Message, EventLogEntryType.Error)
Finally
'Close Database Connection
connection.Close()
End Try
Return output
End Function