0

I am trying to read data from a server on our network using VFPOLEDB.1 however I am getting an error

"Invalid path or file name"

which is caused by a permissions issue.

I have tried using the impersonate in web.config file and also set the application pool account in IIS to admin credentials but still getting the error.

This worked fine I was debugging using my local machine but when debugging using

IIS server

it gave me the error.

Can anyone point me in the right direction please?

Many thanks

user4316519
  • 33
  • 1
  • 8

1 Answers1

0

Given the error message, you should check that the IIS account being used has read/write permissions on the folder where the database files are located.

The account should be something like "IIS AppPool\yourpoolname"

see IIS7 folder permissions for web application

Community
  • 1
  • 1
Steve Bird
  • 222
  • 9
  • 17
  • Thanks for reply, the account that I am logged on to my pc has access to that folder. I have tried impersonating my account in my web.config and also setting the credentials in IIS. Thank you – user4316519 Dec 05 '14 at 09:19
  • If you're accessing the database via IIS then it will be using an IIS account not your local PC account. So permission needs to be granted to the IIS account too. – Steve Bird Dec 05 '14 at 09:24
  • Ok, but I have specified my account for the application pool credentials "mydomain\myusername". Will this not now be the account IIS is using? – user4316519 Dec 05 '14 at 09:30
  • If you've set your account to be used as the application pool identity then, yes, that should be the one that IIS uses to access the database folder. Do you have any Deny permissions set on the folder than might override the Grant permissions? – Steve Bird Dec 05 '14 at 10:05
  • No deny permissions. It is strange I have checked IIS is running under the correct name by using <%= System.Security.Principal.WindowsIdentity.GetCurrent().Name%> and it is correct. I can access the folder from my pc using this account so I am lost – user4316519 Dec 05 '14 at 10:21
  • Now I have set the project back to use local visual studio as host and I can get the data perfectly. But the <%= System.Security.Principal.WindowsIdentity.GetCurrent().Name%> displays the exact username as it did when running on IIS, so why is IIS not working :( – user4316519 Dec 05 '14 at 10:31
  • This is probably obvious but you have confirmed that, in the vfpoledb connection string used on the server, the Data Source does point to the database file on the server? – Steve Bird Dec 05 '14 at 10:47
  • Indeed it does, I am using the UNC path. I may try the ipaddress/foldername/database.dbc rather than servername/foldername/database.dbc – user4316519 Dec 05 '14 at 11:15
  • Doesnt work: Connection string is : @"Provider=VFPOLEDB.1;Data Source=//Servername/VOL10/Folder/DATA/VFP.DBC;Collating Sequence=MACHINE" – user4316519 Dec 05 '14 at 11:56