Web Service cannot connect to Access db on remote server

Posted on 2005-04-12
Last Modified: 2010-04-05
I am writing a web service application using Delphi 2005 (Update2) and
I’m having some problems pointing to an Access db.
Works fine locally but fails when I specify a db on a server (on our LAN).
As a test, I am just counting the rows in a result set.
Hopefully this is a pretty easy solution involving properly specifying the path.

The code for my service looks like this (except for the details
of the select statement):

function TWebService1.ServiceA: string;
var r : BDPDataReader;
    i : Integer;
  BdpDataAdapter1.SelectCommand.CommandText := 'SELECT * FROM …’
  BdpDataAdapter1.Active := True;
  r := BdpDataAdapter1.SelectCommand.ExecuteReader;
  i := 0;
  while r.Read do
  result := IntToStr(i)+ '  RECORDS';

I have set up BdpConnection1 to point to a local copy of the database,
specified as c:\data\mydb.mdb. This works great and I have tested it from
a web client. To point it to the database on a remote server, I specify
something like \\serverX\a\b\mydb.mdb. I am using the Connection Editor
and pointing directly to the file via Network Connections. The “Test” button
says connection is successful. But when I test it running from the IDE, it
always dies on BdpConnection1.Open.

Full text of ConnectionString is:


Ultimately, this service will run on the same server as the database, so I
could probably duplicate the path structure on my local machine and
specify it as localhost:c:\a\b\mydb.mdb. But it may be deployed elsewhere
so I want to specify the actual server name as \\ServerX.

Question by:doug_stephens
    LVL 13

    Accepted Solution

    the problem is access rights, check what user runs your web service, in IIS, go to the scripts virtual folder
    - right click, properties
    - Directory Security
    - Edit

    check the user that is specified in the anonymous access, and if necessary specify an account that can see and has rights to the folder where you have your database
    LVL 1

    Author Comment

    When I connect to the server directory from Windows, I do need to specify a domain / user / password which is
    different than that of my machine, so I think we are on the right track.

    Is the "scripts virtual folder" = the inetpub\wwwroot directory where my web service app lives? I opened
    the properites from IIS Admin and  specified the correct logon info for the anonymous access.
    And got same result when I ran the service - hangs on open.

    Also have checked (under Anon access):  Basic authentication and Integrated Windows authentication.

    LVL 13

    Expert Comment

    just for... just in case... restart IIS

    from the services (Windows Start Menu, Run, type services.msc)
    select IIS Admin Service, right click and Restart

    and try again

    now, your DLL (web service) is in the scripts virtual folder right?... if not, you need to specify the logon information in the folder where your webservice is located
    LVL 13

    Expert Comment

    by the way, if you can put these machines on a domain, or active directory you would have a lot less problems, you would still have to assign a user name with rights on the target machine, but it works a  lot smoother
    LVL 1

    Author Comment

    Restarted IIS. Doesn't seem to want to connect to any database off my local machine,
    no matter what I try with the properties of the virtual folder. Yes, my dll is in there.
    I'll talk to the local network guy. I'm just a consultant here, not properly defined to the network
    so maybe that is the problem. Obviously something wrong with how I'm specifying the access.
    currently I have user as DOMAINNAME\username and have checked "let IIS manage password"
    although I'm not sure what that means.

    I would have expected that if I did not have anon access defined but I had Windows auth checked that
    the system would prompt me for a user / password, but no.

    Also, I wonder why I don't see an exception or any error messages in the IDE. I have a breakpoint on the .open line which I reach
    but that's it. Is that normal?

    Active directory sounds cool but I'd like to get this thing working first. I'm already more than a little overwhelmed with everything
    else I've had to learn recently!

    BTW, how much memory do you need to run B2005? I'm thrashing with 500mb under xpp.
    LVL 1

    Author Comment

    Also, wonder why I get a HTTP 500 error in my browser, instead of 403 Access Denied msg?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
    Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now