Mixaalser684 Posted December 31, 2007 Share Posted December 31, 2007 I watched Total Training tutorial about Dreamweaver 8 and I created dynamic website that connects to Access database and displays the results on webpage. The page works on my localhost, but when I upload it on server (I use free Titanichost.com host) I get some kind of error when I try to preview the page. In the FAQ section of the site it says: How do I connect to my MS Access database?Make sure your database is in the "db" directory in your file space.Here is a sample ASP code to connect to a MS Access database.Dim ConnSet Conn = Server.CreateObject("ADODB.Connection")strConnection = "DRIVER=Microsoft Access Driver(*.mdb);DBQ=" & Server.MapPath("/USERNAME/db/yourdatabase.mdb")oConn.Open(strConnection).......oConn.CloseI'm fairly new to this and I didn't learn the ASP quite that well, just this tutorial, and I don't know where to put the above code, in my own, to make my ASP page appear just as on my loclahost. Can someone help me with this?Here is my ASP page code that Dreamweaver wrote:<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%><!--#include file="Connections/prodavnica.asp" --><% var InfoProdavnice = Server.CreateObject("ADODB.Recordset");InfoProdavnice.ActiveConnection = MM_prodavnica_STRING;InfoProdavnice.Source = "SELECT * FROM Info_Prodavnice";InfoProdavnice.CursorType = 0;InfoProdavnice.CursorLocation = 2;InfoProdavnice.LockType = 1;InfoProdavnice.Open();var InfoProdavnice_numRows = 0;%><%var Repeat1__numRows = -1;var Repeat1__index = 0;InfoProdavnice_numRows += Repeat1__numRows;%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Prodavnica</title></head><body><table width="800" border="1"> <tr> <td><strong>Naziv Prodavnice </strong></td> <td><strong>Vlasnik Prodavnice </strong></td> <td><strong>Ime Poslovodje </strong></td> <td><strong>Prezime Poslovodje </strong></td> <td><strong>Adresa</strong></td> <td><strong>Broj Telefona </strong></td> </tr> <% while ((Repeat1__numRows-- != 0) && (!InfoProdavnice.EOF)) { %> <tr> <td><%=(InfoProdavnice.Fields.Item("Naziv").Value)%></td> <td><%=(InfoProdavnice.Fields.Item("Vlasnik").Value)%></td> <td><%=(InfoProdavnice.Fields.Item("Ime").Value)%></td> <td><%=(InfoProdavnice.Fields.Item("Prezime").Value)%></td> <td><%=(InfoProdavnice.Fields.Item("Adresa").Value)%></td> <td><%=(InfoProdavnice.Fields.Item("BrTelefona").Value)%></td> </tr> <% Repeat1__index++; InfoProdavnice.MoveNext();}%></table></body></html><%InfoProdavnice.Close();%> Link to comment Share on other sites More sharing options...
theodore Posted January 11, 2008 Share Posted January 11, 2008 From the code: Server.MapPath("/USERNAME/db/yourdatabase.mdb")--------------------------------------^The path of the database means SystemDrive/USERNAME/db/yourdatabase.mdbI think the website would not create a user folder under its drive root directory.Instead, you can use relative path, like Server.MapPath("yourdatabase.mdb") and upload the database to the folder with the asp pages. if you upload the databsee to a sub-folder, then Server.MapPath("[subfolder's name]/yourdatabase.mdb")do not put a "/"---^ Link to comment Share on other sites More sharing options...
justsomeguy Posted January 11, 2008 Share Posted January 11, 2008 It looks like those are the instructions from the host, so the path is probably correct. You are including this file on the page:<!--#include file="Connections/prodavnica.asp" -->That file needs the connection string in it, which is what their example is:strConnection = "DRIVER=Microsoft Access Driver(*.mdb);DBQ=" & Server.MapPath("/USERNAME/db/yourdatabase.mdb")You just need to name the connection string the same thing that you're telling the database object to use here:InfoProdavnice.ActiveConnection = MM_prodavnica_STRING;and substitute your username and file path from what they have. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.