Solved

File names

Posted on 2004-08-12
3
152 Views
Last Modified: 2010-04-07
sorry, heres another noob question:
and i apologize if i use incorrect terminology.

on my local server ive been using a specific path name to reference my database location (i.e: C:\aspnet\database.mdb)
when i upload my website to the host how would i reference the database if it is in the same directory as the aspx file? i keep getting errors when i try to use like: /database.mdb or \database.mdb or just database.mdb
does it have something to do with server.MapPath ?? thanks a lot

     'set connection
      dim objConn as new OleDbConnection _
      ("Provider=Microsoft.Jet.OLEDB.4.0;" & _
      "Data Source= what goes here?? ")
0
Comment
Question by:danimbrogno
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 10

Expert Comment

by:Clif
ID: 11785530
If it is in the same folder as the aspx, then reference it directly (no slashes needed):

 'set connection
      dim objConn as new OleDbConnection _
      ("Provider=Microsoft.Jet.OLEDB.4.0;" & _
      "Data Source= myDatabase.mdb ")

Similarly, if it is in a subfolder of the current webfolder, you can reference it starting from the current aspx folder using backslashes *except* no backslash at the beginning:

 'set connection
      dim objConn as new OleDbConnection _
      ("Provider=Microsoft.Jet.OLEDB.4.0;" & _
      "Data Source= databases\myDayabase.mdb ")

It's when it's outside of your current web folder tree that you get in trouble.
0
 

Author Comment

by:danimbrogno
ID: 11786001
for some reason that doesnt work... but ive solved the problem, i ended up using this code

("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & server.mappath("products.mdb"))

Ill give the points if someone knows why i needed the server.mappath deal... it stumps me
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 250 total points
ID: 12070909
Using Server.MapPath
http://www.4guysfromrolla.com/webtech/121799-1.shtml

"Each file on a Web server has two ways of being accessed - through a virtual path and through a physical path..."

Bob
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question