Ecommerce Templates > ASP Version Help > Making the database connection

Setting your database connection

Once you've got your store published to your server, you may well find that the path to the database is not correct and the database doesn't have write permissions. Below we've outlined the simple steps to take to right these issues.

Setting the path to your database

The easiest way to do this is by setting up a quick test file and then copying the contents into your db_conn_open.asp file in the vsadmin folder - here's how to do it:

  • Open notepad, copy and paste the following lines of code:

    <HTML>
    <BODY>
    sDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=<%=server.mappath("vsproducts.mdb")%>;"
    </BODY>
    </HTML>

  • Save the file as test.asp
  • Upload this file to your fpdb folder (the one where your database resides)
  • Now open this page in your browser, the URL should be something like www.yourdomain.com/fpdb/test.asp
  • Copy the contents of that page - it should look something like this
    sDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\web\database\vsproducts.mdb;"
  • Open the file db_conn_open.asp in notepad and replace the current content with what you have copied from test.asp - just make sure that you don't delete the opening and closing <% %> tags so your code in db_conn_open.asp should look something like this:
    <%
    sDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\web\database\vsproducts.mdb;"
    %>
  • Upload your new db_conn_open.asp to your server, overwriting the original in the vsadmin folder
  • That should be working fine now and you can check it at www.yourdomain.com/vsadmin/login.asp
  • If you get an error that the test.asp page cannot be found then it is very likely that the page cannot be executed. In that case place the test.asp file in your images folder and browse to yoursite.com/images/test.asp, copy the connection string you get there, paste it into vsadmin/db_conn_open.asp replacing the \images\ in the string with \fpdb\
  • Important: Once you have the database connection set up, check that it is not possible to download it by typing in the URL of the database location in your browser. This will be something like www.yoursite.com/fpdb/vsproducts.mdb - it is very important that your database directory is not browseable. Please check with your host if you have any doubts at all. Most hosts will provide you with a directory below the root of your web with the correct permissions already set.
  • NOTE: If you are on a Windows 2008 server you will need to update your connection string to use the 64-bit Access driver.This means instead of using something like this...
    sDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\inetpub\wwwroot\fpdb\vsproducts.mdb;"
    ...use something like this...
    sDSN = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\inetpub\wwwroot\fpdb\vsproducts.mdb;"

SECURITY TIP
The best place for your database is outside the web root. Most hosts provide a special folder for this with the database permissions already set. Using a folder outside the web root will make it difficult for anyone to download your database and gain access to your username and password. Otherwise you must set the permissions on your database folder so that your database cannot be downloaded. More information is available here.

SECURITY TIP
Rename your database from vsproducts.mdb to a name of your choice, (keeping the .mdb extension of course).
Examples would be (though don't use ours) yourstore591.mdb or database2221.mdb
This will make it harder for anyone to find your database if your database folder permissions are set incorrectly.

Giving your database write permissions

Once that is done it's possible you will see a message that your database doesn't have write permissions. Your host will be able to change this for you

If you are using Godaddy as your host then you can follow the steps in our pdf document here