Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 19th, 2008, 10:45 AM
Registered User
 
Join Date: May 2008
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Database Location

Hi

I have made a ASP page that looks at a database and displays the data on a webpage but i cant put the Database on a server it some up with an error saying that the file doesnt exist if i give it a fixed path e.g. f:\home\databases\employees.mdb

How can i edit my code so that it will look to this location ?

here is my code

Code:
<% 
    pStr = "private, no-cache, must-revalidate" 
    Response.ExpiresAbsolute = #2000-01-01# 
    Response.AddHeader "pragma", "no-cache" 
    Response.AddHeader "cache-control", pStr 
%>

<head>
    <style>
    td { font-size : 8pt; font-family : Verdana, Arial; text-decoration : none; }
    body { font-size : 8pt; font-family : Verdana, Arial; text-decoration : none; }
    </style>
</head>

<body>
<p align="center"><b>All Records Entered :</b></p>
<table align="center" border=0 cellpadding=3 cellspacing=3 cols=2 width=400>
<%
   ' Declaring variables
   Dim rs, data_source, no
   no = 0
   data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _ 
            Server.MapPath("employee.mdb")

   ' Creating Recordset Object and opening the database
   Set rs = Server.CreateObject("ADODB.Recordset")
   rs.Open "employees", data_source
   ' Looping through the records to show all of them
   While Not rs.EOF %>
<form action="del.asp" method="post">
<tr>
    <td align="right" height=10 valign="top">First Name :</td>
    <td align="left" height=10 valign="top" width=250><%=rs("firstname") %></td>
</tr>
<tr>
    <td align="right" height=10 valign="top">Sur Name :</td>
    <td align="left" height=10 valign="top" width=250><%=rs("surname") %></td>
</tr>
<tr>
    <td align="right" height=10 valign="top">Department :</td>
    <td align="left" height=10 valign="top" width=250><%=rs("Department") %></td>
</tr>
<tr>
    <td align="right" height=10 valign="top">Site :</td>
    <td align="left" height=10 valign="top" width=250><%=rs("Site") %></td>
</tr>
<tr>
    <td align="right" height=10 valign="top">Ext :</td>
    <td align="left" height=10 valign="top" width=250><%=rs("EXT") %></td>
</tr>
<tr>
    <td align="right" height=10 valign="top">DDI :</td>
    <td align="left" height=10 valign="top" width=250><%=rs("DDI") %></td>
</tr>
<tr>
    <td align="right" height=10 valign="top">Mobile :</td>
    <td align="left" height=10 valign="top" width=250><%=rs("Mobile") %></td>
</tr>
<tr>
    <td align="right" height=10 valign="top">Email :</td>
    <td align="left" height=10 valign="top" width=250><%=rs("Email") %></td>
</tr>
<tr>
    <td align="right" height=10 valign="top"><input type="hidden" name="id" value="<%=rs("id")%>"></td>
    <td align="left" height=10 valign="top" width=250><input type="submit" value="Delete" style="height: 25px; width: 100px"></td>
</tr>
</form>
<tr>
    <td align="right" height=10 valign="top"><input type="hidden" name="first_name" value="<%=rs("firstname")%>"></td>
</tr>

  <%
   no = no + 1
   rs.MoveNext
   Wend
   ' Done. Now close the Recordset
   rs.Close
   Set rs = Nothing
 %>
 <tr>
    <td align="right" height=10 valign="top"><b>Total Records Found</b> :</td>
    <td align="left" height=10 valign="top" width=250><%= no %></td>
</tr>
 </table>
</body>
</html>
Can anyone help?

 
Old May 19th, 2008, 12:43 PM
Friend of Wrox
Points: 2,101, Level: 18
Points: 2,101, Level: 18 Points: 2,101, Level: 18 Points: 2,101, Level: 18
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2003
Location: , , .
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

Check out this link. I think it might have something to do with how you are using Server.MapPath:

http://www.4guysfromrolla.com/webtech/121799-1.shtml

 
Old May 20th, 2008, 07:51 AM
Registered User
 
Join Date: May 2008
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am not sure how i can change it can anyone tell me how i can hard code it in
i have tryed to create a database with linked table but it still says that it cant find the database location





Similar Threads
Thread Thread Starter Forum Replies Last Post
Database at different location gaurav_jain2403 ADO.NET 4 May 29th, 2006 12:50 AM
Subreport with database location issue dantetang BOOK: Professional Crystal Reports for VS.NET 0 September 4th, 2005 11:09 PM
Changing Database Location in Runtime jstokes8447 Crystal Reports 0 December 28th, 2004 06:37 PM
Set Database Location dazzer Crystal Reports 1 July 26th, 2004 09:33 AM
Database Location egerdj BOOK: Beginning ASP 3.0 1 February 20th, 2004 04:27 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.