?
Solved

can't access database using Server.MapPath in apache

Posted on 2005-03-03
13
Medium Priority
?
263 Views
Last Modified: 2008-03-06
Hi!

I'd like to ask if there's a way I can access the database using Server.MapPath in apache?
Here's my sample code:
strTemp = new String(Server.MapPath('pal.mdb'))
strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strTemp + ";Persist Security Info=False"
var objConn = Server.CreateObject("ADODB.Connection")
objConn.Open(strConnect)

Hope you can help me out! :)

Thanks!
0
Comment
Question by:coolnsimple
[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
  • 8
  • 3
  • 2
13 Comments
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 13449960
Server.MapPath is a ASP object.method.  ASP is specific to Windows IIS servers.

Apache web server does not have ASP objects.
0
 
LVL 8

Expert Comment

by:tomvergote
ID: 13450071
unless he is using chilisoft or something
Coolnsimple could you provide more information about your environment?

One thing i think of right away:
new String(Server.MapPath('pal.mdb')) should be new String(Server.MapPath("pal.mdb")) with double quotes.
Maybe your apache config is a bit more strict in executing buggy scripts

BTW:
strTemp = new String(Server.MapPath('pal.mdb'))
>> This shows your database is inside your website, that is very bad practice since it allows anyone to download it.
If somebody does a request to http://www.yourserver.org/pal.mdb they'll just download the file (I hope there aren't any sensitive data in it)
Yeah I know they'll have to know the filename, but a random asp error could display the database location to your visitors.

I would suggest you move your database somewhere outside your website root
0
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 13451131
ChiliASP was bought by SUN.  I don't think they offer an Apache version any more....but it could be an old version.
0
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 
LVL 29

Expert Comment

by:rdivilbiss
ID: 13452744
tomvergote,

Maybe he is using this:

http://www.apache-asp.org/config.html

0
 
LVL 8

Expert Comment

by:tomvergote
ID: 13453246
could be, I didn't know about it, thanks for the link.
As long as he doesn't post back I'm assuming his config borks on the single quote thing
0
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 13454022
I didn't know about it either.  Wasn't even looking for it.  Just stubled across it.

Might be pretty interesting, although I doubt I'll run downstairs and build an Apache box today.
0
 

Author Comment

by:coolnsimple
ID: 13456519
Hi!  Tried the double quote thing but didn't work...
Im under windows NT and I'm using apache2.0...
I tried to check on the config file httpd, but didn't know what parameters or settings to modify, also didn't know if new settings would help to access database.

Tomvergote, thanks for the advice, but this would be used in the intranet only and there wouldn't be any important data in it. :)
0
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 13458945
Your map path may be included in you connection string.  You should not need the persist security for access.  This is a working connection string.

connection = ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/database/examples.mdb"))
0
 
LVL 8

Expert Comment

by:tomvergote
ID: 13461318
but we still don't know how he is running asp :)
Neither if he get's an indicative error message
0
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 13461833
True, but I'm assuming the Apache-ASP link I found.
0
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 13552440
coolnsimple.

Did these suggestions help you solve your problem or do you still need assistance?

Regards,
Rod
0
 

Author Comment

by:coolnsimple
ID: 13552686
I still do need some assistance, I tried to search also for solution but didn't find any.  Hopefully you guys would be able to suggest a better web server...
Unfortunately, I don't have an installer for window nt server so I don't have IIS, as for apache, it also seems that it cannot read include files, when I tried to cut 1 asp page to several parts and have them included in the codes like "<!--#include file="incTop.asp"-->", apache can't seem to recognize and does not display the include files.
So I'm looking for a freeware and better web server which can be compatible with asp objects...better if you'd be able to provide me a link with the installer. :)

Thanks!
0
 
LVL 29

Accepted Solution

by:
rdivilbiss earned 1000 total points
ID: 13556277
Did you look at http://www.apache-asp.org

the syntax is a bit different from IIS

e.g. <!--#include file=filename.inc-->

instead of <!--#include file="filename.inc"-->

AND

$Server->MapPath($url);

instead of

Server.MapPath("url")

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Suggested Courses
Course of the Month8 days, 10 hours left to enroll

764 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