Solved

File names

Posted on 2004-08-12
3
149 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
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

830 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