Help I am at a total loss-File in use Error

  • Thread starter Thread starter Chris Lane
  • Start date Start date
C

Chris Lane

After Compact and repair of a access.mdb, My webform can
no longer open the .mdb file. I have restarted IIS twice.
I have stopped and restarted the web several time. I have
removed the application and recreated the application.
Nothing works eithier I changed some code by accident or
there is something I am overlooking.

Here is the error:

System.Data.OleDb.OleDbException: The Microsoft Jet
database engine cannot open the
file 'C:\Inetpub\wwwroot\_database\Test.mdb'. It is
already opened exclusively by another user, or you need
permission to view its data.
at System.Data.OleDb.OleDbConnection.ProcessResults
(Int32 hr)
at System.Data.OleDb.OleDbConnection.InitializeProvider
()
at System.Data.OleDb.OleDbConnection.Open()
at Forms.AddStore.GetDataReader(String ConnString,
String sSql) in
C:\Inetpub\wwwroot\Forms\AddStore.aspx.vb:line 312
at Forms.AddStore.FillStatesDDL(Int32 CountryID) in
C:\Inetpub\wwwroot\Forms\AddStore.aspx.vb:line
244System.Data.OleDb.OleDbException: The Microsoft Jet
database engine cannot open the
file 'C:\Inetpub\wwwroot\_database\Test.mdb'. It is
already opened exclusively by another user, or you need
permission to view its data.
at System.Data.OleDb.OleDbConnection.ProcessResults
(Int32 hr)
at System.Data.OleDb.OleDbConnection.InitializeProvider
()
at System.Data.OleDb.OleDbConnection.Open()
at Forms.AddStore.GetDataReader(String ConnString,
String sSql) in
C:\Inetpub\wwwroot\Forms\AddStore.aspx.vb:line 312
at Forms.AddStore.FillCountriesDDL(Int32 intSelected)
in C:\Inetpub\wwwroot\Forms\AddStore.aspx.vb:line 285

It is failing on the Connection object open method.

Here is the code:

Private Sub FillStatesDDL(ByVal CountryID As Int32)

Dim sConnString As String
Dim sSql As String = "SELECT Full_Name FROM States
WHERE Country_ID = " & CountryID & " ORDER BY Full_Name"

Try
sConnString = GetConnStr
("../_database/Test.mdb")

With ddlStates
.DataSource = GetDataReader(sConnString,
sSql)
.DataTextField = "Full_Name"
.DataValueField = "Full_Name"
.DataBind()
End With
Catch exc As Exception
Response.Write(exc)
Finally
'Close Objects and set them to nothing
CleanUp()
End Try
End Sub

Private Function GetConnStr(ByVal sDbFile As String) As
String
GetConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;" &
_
"Data Source=" & Server.MapPath(sDbFile) & ";"
& _
"User ID=;Password=;" ' You could use a
Username and Password here.
End Function

Private Function GetDataReader(ByVal ConnString As
String, ByVal sSql As String) As Data.OleDb.OleDbDataReader
'Add Data access code here
m_oOleDbConn = New OleDbConnection(ConnString)
m_oOleDbConn.Open()
m_oOleDbCmd = New OleDbCommand(sSql, m_oOleDbConn)
m_odrFill = m_oOleDbCmd.ExecuteReader()
Return m_odrFill
End Function

Private Sub CleanUp()
'Close the connection to the data source and
dispose of objects
If Not m_odrFill Is Nothing Then
m_odrFill.Close()
End If
m_oOleDbCmd = Nothing
If m_oOleDbConn.State = ConnectionState.Open Then
m_oOleDbConn.Close()
End If
m_oOleDbConn.Dispose()
End Sub

I still think IIS has a lock on it somehow but I don't
know what else to try.

Thanks
 
Hi Chris,


Chris Lane said:
After Compact and repair of a access.mdb, My webform can
no longer open the .mdb file. I have restarted IIS twice.
I have stopped and restarted the web several time. I have
removed the application and recreated the application.
Nothing works eithier I changed some code by accident or
there is something I am overlooking.

Does aspnet account has write&read privileges on the mdb file in question?
 
-----Original Message-----
Hi Chris,




Does aspnet account has write&read privileges on the mdb
file in question?

Yes. The sttrange this is this working fine on a hosting
server just not on my local server all of a sudden after
doing the compact.
 
Does aspnet account has write&read privileges on the mdb
file in question?

Yes. The sttrange this is this working fine on a hosting
server just not on my local server all of a sudden after
doing the compact.

Since compacting produces a new file I would double check the security
privileges for the mdb file.
Also, what happens if you open it with Access application?
There is also a possibility that mdb file is open in another app (Access)
while aspnet is trying to open it (exclusively?).
 
security settings allow everyone and access is not open.
Now after messing around trying to fix it I am having
problems opening it with VS.NET cause the file path
doesn't match the URL.
 
Back
Top