[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.odbcnet

Bug in ODBC.NET after compacting Access Database?

Girish Bhatia

1/21/2003 8:38:00 PM


Ok, after 2 days of racking my brains on why this is
happening, I am positive that there is a bug in the
ODBC.NET driver and am wondering if anyone can confirm
this, or is this a known issue. This is related to the
post titled - "Connection Error" by me.

I have Access 2000 installed on my machine (W2k
Professional) which is the database for my web app. I
installed it from the MSDN CD's (Office 2000 SR-1
Premium). So long as I work with the database without
compacting it, it works fine. Once I compact the database,
and then try to access the webapp, i get the following
error -

ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]
The Microsoft Jet database engine cannot open the
file '(unknown)'. It is already opened exclusively by
another user, or you need permission to view its data.
ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's
SQLSetConnectAttr failed ERROR [HY000] [Microsoft][ODBC
Microsoft Access Driver] The Microsoft Jet database engine
cannot open the file '(unknown)'. It is already opened
exclusively by another user, or you need permission to
view its data.

The stack trace is


[OdbcException: ERROR [HY000] [Microsoft][ODBC Microsoft
Access Driver] The Microsoft Jet database engine cannot
open the file '(unknown)'. It is already opened
exclusively by another user, or you need permission to
view its data.
ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's
SQLSetConnectAttr failed
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]
The Microsoft Jet database engine cannot open the
file '(unknown)'. It is already opened exclusively by
another user, or you need permission to view its data.]
Microsoft.Data.Odbc.OdbcConnection.Open()
Data_Layer.DataManager.LogError(String strFromObj, String
strFromMethod, String strErrorText, Int32 iErrNo, String
strSource) in C:\Documents and Settings\gibhatia\My
Documents\Visual Studio Projects\TB\Data
Layer\DataManager.vb:112
TB.TBWeb.Login.cmdLogin_Click(Object sender, EventArgs e)
in c:\inetpub\wwwroot\tbweb\login.aspx.cs:94
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEve
ntHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent
(IPostBackEventHandler sourceControl, String
eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection
postData)
System.Web.UI.Page.ProcessRequestMain()


Can anyone please confirm if this is happening with them
too? Is there a known issue about working with the
ODBC.NET driver after the database has been
compacted/repaired?

Once this happens, if I create a new database (.mdb file)
and export/import the tables from the old database into
the new db, everything works fine. I find this weird, and
dont seem to have a reason why this should happen.

Can anyone share their thoughts on why this is happening?
Are there any patches to O2K SR-1 that I need to install?

Thanks,
Girish

3 Answers

(Hussein Abuthuraya(MSFT))

1/23/2003 3:20:00 AM

0

Hi Girish,

OK, here is the explanation to what you are seeing. ODBC.NET or the ODBC driver has nothing to do with what you are seeing in regard to the permissions.

What's happening is that the Compact operation that uses Jet to accomplish this is not aware of the NTFS file permissions you have on the mdb file. So in order to compact
the database, the Access UI has to create new database from the old one and delete the old. Since its not aware of the File Permissions (can't read them) then it creates the
new MDB file with everyone or no permissions (depending on the folder settings). Now every time you compact an MDB file, you need to set the NTFS file permissions
again. If you are compacting the database file in code, you may write a program that reads the old mdb file permissions and then apply them to the new MDB file.

Please note that this is not a problem if you are using a Windows Application where File Permissions are not considered but in a Web Application this is big deal and you
have to have the correct file permissions or you will not have access.

I hope this helps!


Thanks,
Hussein Abuthuraya
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.co....


Jeppe

1/23/2003 12:21:00 PM

0

I get the same error but I'm not using ODBC. however if this is true what
you say then why does it start working again after you restart the computer?

"Hussein Abuthuraya(MSFT)" <HussAbOnline@microsoft.com> wrote in message
news:sBV8vXowCHA.2460@cpmsftngxa08...
> Hi Girish,
>
> OK, here is the explanation to what you are seeing. ODBC.NET or the ODBC
driver has nothing to do with what you are seeing in regard to the
permissions.
>
> What's happening is that the Compact operation that uses Jet to accomplish
this is not aware of the NTFS file permissions you have on the mdb file. So
in order to compact
> the database, the Access UI has to create new database from the old one
and delete the old. Since its not aware of the File Permissions (can't read
them) then it creates the
> new MDB file with everyone or no permissions (depending on the folder
settings). Now every time you compact an MDB file, you need to set the NTFS
file permissions
> again. If you are compacting the database file in code, you may write a
program that reads the old mdb file permissions and then apply them to the
new MDB file.
>
> Please note that this is not a problem if you are using a Windows
Application where File Permissions are not considered but in a Web
Application this is big deal and you
> have to have the correct file permissions or you will not have access.
>
> I hope this helps!
>
>
> Thanks,
> Hussein Abuthuraya
> Microsoft Developer Support
>
> This posting is provided "AS IS" with no warranties, and confers no
rights.
>
> Are you secure? For information about the Microsoft Strategic Technology
Protection Program and to order your FREE Security Tool Kit, please visit
> http://www.microsoft.co....
>
>


(Hussein Abuthuraya(MSFT))

1/23/2003 9:24:00 PM

0

You can try it for yourself, add any specific account (say IUSR_machinename) to the security list that have permissions to the mdb file then from Access compact the mdb.
Now check the accounts list and the new account that you have added will not be there.

Again this has nothing to do with ODBC, its all related to the NTFS file permissions of the mdb file. Web Application these file permissions set correctely so that IIS will be
able to access the file.

Your scenario may be different so I can't say why after restarting, you application works.


Thanks,
Hussein Abuthuraya
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.co....