简体   繁体   中英

Error querying dbf file from network share using Microsoft.ACE.OLEDB.12.0

Windows Server 2008 R2 x64 SP1, Sql Server 2008 x64 SP3, Access Database Engine x64 SP1

I have linked server:

EXEC master.dbo.sp_addlinkedserver @server = N'dbf2', @srvproduct=N'dbf2', @provider=N'MSDASQL', @provstr=N'DRIVER={Microsoft Access dBASE Driver (*.dbf, *.ndx, *.mdx)};'

When querying dbf file from local disk everything is OK:

select * from openquery(dbf2, 'select * from c:\\V4C8MA6.dbf') a

But when querying from network share

select * from openquery(dbf2, 'select * from \\\\gefest\\upload\\V4C8MA6.dbf') a

I've got the error:

Msg 7399, Level 16, State 1, Line 6
The OLE DB provider "MSDASQL" for linked server "dbf2" reported an error. The provider did not give any information about the error.
Msg 7350, Level 16, State 2, Line 6
Cannot get the column information from OLE DB provider "MSDASQL" for linked server "dbf2".

I've tried different variants to describe the path: [], "", ``, \\"\\", .... Everything is OK with the nework share access, the sql server account has needded access rights. But...

How to make it work?

Added on 04 may 2012:

xp_cmdchell lists the directory perfectly.

This is what I discovered: I created linked server with sprovstr indicating the location of the file:

@provstr=N'DRIVER={Microsoft Access dBASE Driver (*.dbf, *.ndx, *.mdx)};dbq=\\gefest\upload'

This works if I connect to the sql server using sql server auth .

This is what ProcMon shows when using dbq :

Date & Time: 5/4/2012 9:57:55 AM
Event Class: File System
Operation: CreateFile
Result: SUCCESS
Path: \\\\gefest\\upload\\
TID: 8588
Duration: 0.0001988
Desired Access: Read Attributes
Disposition: Open
Options: Open Reparse Point
Attributes: n/a
ShareMode: Read, Write, Delete
AllocationSize: n/a
OpenResult: Opened

This is when indicating path in the query :


Date & Time: 5/4/2012 9:58:53 AM
Event Class: File System
Operation: CreateFile
Result: OBJECT PATH INVALID
Path: \\\\gefest\\upload\\
TID: 8588
Duration: 0.0000819
Desired Access: Read Attributes
Disposition: Open
Options: Open Reparse Point
Attributes: n/a
ShareMode: Read, Write, Delete
AllocationSize: n/a

Why sql server receives desired access to the share at the first query and does not at the second?

The third and fourth variants are when connecting to the server using windows auth :

using dbq :


Date & Time: 5/4/2012 10:02:54 AM
Event Class: File System
Operation: CreateFile
Result: ACCESS DENIED
Path: \\\\gefest\\upload\\
TID: 8588
Duration: 0.0031837
Desired Access: Read Attributes
Disposition: Open
Options: Open For Backup, Open Reparse Point
Attributes: n/a
ShareMode: Read, Write, Delete
AllocationSize: n/a
Impersonating: GAZ\\kozlovai

indicating path in the query :


Date & Time: 5/4/2012 10:02:20 AM
Event Class: File System
Operation: CreateFile
Result: OBJECT PATH INVALID
Path: \\\\gefest\\upload\\
TID: 8588
Duration: 0.0000378
Desired Access: Read Attributes
Disposition: Open
Options: Open For Backup, Open Reparse Point
Attributes: n/a
ShareMode: Read, Write, Delete
AllocationSize: n/a
Impersonating: GAZ\\kozlovai

Sql server impersonates when connecting to the share. And this account 'GAZ\\kozlovai' has full access to the share, but sql server still cannot open the file...

Check to see if the user idenity under which the query runs has read and write access to the temp folder on the server. This is because SQL Server will create temp files for the query under the context of the calling user, not the SQLServer process account.

EDIT : I recall at least some instances of this problem arising only via UNC hosted shares, so it isn't a lead-pipe cinch it would happen on the local reference.

Just for grins, fire up an XP_CMDSHELL and perform a 'DIR \\\\SERVER\\SHARE\\FOLDER' and make certain you can talk to that path via UNC within SQL Server. If not, you still have an access issue to overcome.

Lastly, if all else fails, and you have login access to the server, I'd fire up a copy of Process Monitor and watch for network IO issues when that query fires.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM