Jump to content
Sign in to follow this  
Mixaalser684

How to make ASP page and Database display on web

Recommended Posts

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.Close
I'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();%>

Share this post


Link to post
Share on other sites

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 "/"---^

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...