locked
Can't use relative file path for database connection RRS feed

  • Question

  • I am using EW 4

    When I set up a database connection to an Access database on the website on my local computer it tests OK and beahves as expected in preview.

    However when published to the remote server it gives an error because it is trying to access C: etc on my hard disc. I have tried entering a relative path name for the connection but it won't recognize it and keeps trying to use an absolute path name on my hard drive.

    How can I fix this

    Thanks,

    Sam

    Thursday, March 6, 2014 1:44 AM

Answers

All replies

  • You need to modify the connection string to the correct one for your hosted site. You didn't tell us what kind of database or where the database is, so I can't be any more specific than that, but your host can usually help with this.
    Thursday, March 6, 2014 1:47 AM
  • Thank you

    Unfortunately my host has only recently installed asp net 4 and have little knowledge of how it works.

    I am using a Microsoft Access database which is housed in the fpdb directory of my website - a legacy of Frontpage. Its filename is fpdb/Events.mdb and it has worked fine for years and contunues to do so under asp and Frontpage with no host-specific code required. 

    Within EW when I attempt to convert the absolute filename to a relative one it will not accept it (on my home computer) and just tries to turn it into an absolute one.

    Thursday, March 6, 2014 2:09 AM
  • If you are working with asp, I can't help you.  If you are working with asp.net, I might be able to.  Which do you mean?

    Thursday, March 6, 2014 4:06 AM
  • Thank you Kathy

    I have solved the problem. I was making the connection using 'Microsoft Access Database File' and that worked fine on the local computer but not on the host

    I found that using AccessData Source works fine - by the way I am working on asp and asp.net on the same website while I transition

    Thank you

    Thursday, March 6, 2014 4:17 AM
  • I'm glad you have it sorted.

    But do one more thing since you are moving to asp.net:  Create an App_Data folder in your site (right in the root), and move your database into that.  That folder has a special meaning for asp.net: it is protected, and is intended for just what you are doing, having a database within your site file structure.

    Thursday, March 6, 2014 4:20 AM
  • Thank you Kathy - I will do that
    • Marked as answer by White Hat Aus Thursday, March 6, 2014 4:30 AM
    Thursday, March 6, 2014 4:22 AM