logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > ASP
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 07-07-2009, 07:29 PM   #1
paulgt
 
Join Date: Mar 2009
Posts: 2
Default Using Server.MapPath in a connection string

Hi everyone.
I wonder if someone can help me.

I have designed an ASP web site using DW CS4 and I have a problem using Server.MapPath in the database connection string. The database is Access 2003.

If i use a direct path in the connection string e.g.
Code:
<%
// FileName="Connection_ado_conn_string.htm"
// Type="ADO" 
// DesigntimeType="ADO"
// HTTP="true"
// Catalog=""
// Schema=""
var MM_DatabaseSVBB_STRING = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:/inetpub/wwwroot/database/svbb.mdb"
%>
Everything works fine... but this is obviously no good on a web server, so I am trying to use a Server.MapPath command as below:

Code:
<%
// FileName="Connection_ado_conn_string.htm"
// Type="ADO" 
// DesigntimeType="ADO"
// HTTP="true"
// Catalog=""
// Schema=""
var MM_DatabaseSVBB_STRING = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="& Server.MapPath("/database/svbb.mdb")
%>
However, this version always causes the error

Quote:
ADODB.Command error '800a0bb9'
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
/index.asp, line 6
The bit of the web page that crashes is as below:
HTML Code:
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%>
<%Session.LCID = 2057%>
<!-- #include file="Connections/DatabaseSVBB.asp" -->
<%
var rsQueryAll10Days_cmd = Server.CreateObject ("ADODB.Command");
rsQueryAll10Days_cmd.ActiveConnection = MM_DatabaseSVBB_STRING;
rsQueryAll10Days_cmd.CommandText = "SELECT * FROM QueryAll10days ORDER BY [Date], [Time] ASC";
rsQueryAll10Days_cmd.Prepared = true;

var rsQueryAll10Days = rsQueryAll10Days_cmd.Execute();
var rsQueryAll10Days_numRows = 0;
%>
I do hope someone is able to advise me on this..
Thanks in anticipation
PaulGT
paulgt is offline   Reply With Quote
Old 08-17-2009, 04:19 PM   #2
mangofreak
mangofreak's Avatar
 
Join Date: Jan 2006
Location: Toronto-Canada
Posts: 444
Default

Did you know that MapPath only works when the DB is on the same directory as the files you are working on? Also, password you database. I had nightmares with Access files being hacked by Pakistany hackers and some Other hooligans from Turkey. Also, validate forms and the whole works.
__________________
J.
DW | FW | HTML | CSS | ASP | some PHP | Windows | Ubuntu
mangofreak is offline   Reply With Quote
Old 08-17-2009, 06:16 PM   #3
paulgt
 
Join Date: Mar 2009
Posts: 2
Default

Hi
thanks for your response. I was beginning to wonder if anyone would.
Your information is very useful. I will re-think my strategy.
Paulgt
paulgt is offline   Reply With Quote
Old 08-17-2009, 06:28 PM   #4
mangofreak
mangofreak's Avatar
 
Join Date: Jan 2006
Location: Toronto-Canada
Posts: 444
Default

No problem. I have been absent from the forum for months now, but I'll be checking it more often. Let me know how it goes.

Cheers,

Javier
__________________
J.
DW | FW | HTML | CSS | ASP | some PHP | Windows | Ubuntu
mangofreak is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:11 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com