If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Server path to access databse

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-08-05, 05:24
sam_h sam_h is offline
Registered User
 
Join Date: Nov 2005
Posts: 1
Server path to access databse

Hi all. I'm in need of help with this one. (see code below)

The file connects to an access database to populate drop down boxes. This all works fine when tested on my local personal web server. Now i need to get this online but I can't get it to worlk.

I have tried this code;

Code:
var strconnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("FAQS.mdb")
This did not work and all i get is a 500 server error. Can anyone see where im going wrong or where the problem lies? My server can handle asp and my database is in the same folder as my asp file. I can supply the database if anyone needs it.

Many thanks in advance for any help.

Sam.
(P.s. my appologies for the long list of code)


Code:
<%@ language = "Javascript" %>
<%

var strQuestion = "";
if (Request.Querystring("stateChanged") == "true")
{
strQuestion = Request.Form("cboQuestion");
}
var strconnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/testfolder/databases/FAQS.mdb";
%>
<script language=Javascript>
function initControls()
{
populateQuestion();
populateType();
}
function populateQuestion()
{
<%
var rs = Server.CreateObject("ADODB.Recordset");
var sql = "select distinct Question from tblQuestions order by Question"
rs.Open(sql,strconnection);
var n=0;
while (!rs.EOF)
{
var stateID = rs.Fields("Question");
var stateDesc = rs.Fields("Question");
Response.Write("document.frmTest.cboQuestion[" + n + "] = new Option('" + stateDesc+ "','" + stateID + "');");

if (new String(strQuestion).search(stateID) != -1)

Response.Write("document.frmTest.cboQuestion[" + n + "].selected = true;");
rs.MoveNext();
n++;
}
rs.Close();
%>
}

function populateType()
{
<%
if (strQuestion != "")
  {
	var rs2 = Server.CreateObject("ADODB.Recordset");
	var strSql = "select distinct SubQuestion from tblQuestions where Question = '" + strQuestion + "' ";
	rs2.Open(strSql,strconnection);
	var n=1;
	while (!rs2.EOF)
		{
			var strType = rs2.Fields("SubQuestion");
			Response.Write("document.frmTest.cboSubQuestion[" + n + "] = new Option('" + strType + "','" + strType + "');");
			rs2.MoveNext();
			n++;
		}
		rs2.Close();
	}
%>
}
function fillType()
	{
		document.frmTest.action = "contact-sam3.asp?stateChanged=true";
		document.frmTest.submit();
	}
		function saveData()
	{
		document.frmTest.action = "./contact-sam3.asp";
		return true;
	}

</script>

<html>
<head>
<title>Multi Dropdown Selecting Value from one second will Display its corresponding values</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- Fireworks MX Dreamweaver MX target.  Created Tue Aug 19 09:32:36 GMT+0500 (West Asia Standard Time) 2003-->
<script language="javascript">
<!--

function dept_onchange(frmTest) {
	frmTest.submit(); 
}

//-->
</script>

</head>
<body onload = "initControls();" bgcolor="#ffffff" link="#666666" vlink="#666666" alink="#666666" leftmargin="0" topmargin="0">
<table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
  <!-- fwtable fwsrc="index.png" fwbase="default.jpg" fwstyle="Dreamweaver" fwdocid = "742308039" fwnested="1" -->
  <tr>
   <td>
      <table border="0" cellpadding="0" cellspacing="0" width="780">
        <tr> 
          <td>&nbsp;</td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
   <td><table border="0" cellpadding="0" cellspacing="0" width="780">
	  <tr>
	      <td valign="top">
            <table width="220" border="0" cellpadding="0" cellspacing="0" bgcolor="#D6E6F3">
              <tr> 
                <td valign="top" bgcolor="96C2DD"> <strong style="font-weight: 400"> 
                  <font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FFFFFF"> 
                  Question &amp; SubQuestion</font></strong></td>
              </tr>
              <tr> 
                <td valign="top"> 
                  <form name="frmTest" method="post" action="contact-sam3.asp">
                    <table width="220" border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
                      <tr valign="top" bgcolor="#D6E6F3"> 
                        <td height="25" colspan="2" width="220"> 
                          <select name="cboQuestion" onChange="fillType()">
                            <option value="Select Question" selected>Select Question</option>
                          </select>
                        </td>
                      </tr>
                      <tr bgcolor="#D6E6F3"> 
                        <td width="153" valign="top" bgcolor="#D6E6F3"> 
                          <SELECT name=cboSubQuestion LANGUAGE=javascript onchange="return dept_onchange(frmTest)">
						  <option value="Select Question" selected>Select Question</option>
						  </select>
                        </td>
                        <td width="67" bgcolor="#D6E6F3"> 
                          <INPUT TYPE = "Submit" VALUE = "GO>>>>">
                        </td>
                      </tr>
                    </table>
                  </form>
                </td>
              </tr>
            </table>
          </td>
	      <td align="right">&nbsp; </td>
	  </tr>
	</table></td>
  </tr>
</table>
The following was selected : <%=Request.Form ("cboSubQuestion")%>
</body>
</html>

Last edited by sam_h; 11-08-05 at 05:43.
Reply With Quote
  #2 (permalink)  
Old 11-08-05, 15:36
lynn22 lynn22 is offline
Registered User
 
Join Date: May 2005
Posts: 17
Have a try with the following connection string (see &";" added at the end of the line)

var strconnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("FAQS.mdb") &";"
Reply With Quote
  #3 (permalink)  
Old 11-08-05, 18:27
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
I'd recommend some debugging.... write out the path it is going to use... as I suspect your path must be incorrect and you connection is failing.
Code:
Response.Write Server.MapPath("FAQS.mdb")
var strconnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("FAQS.mdb")
You could also wrap the call that opens the connection in an error trap and report out what the error is (bypassing the http 500).
Reply With Quote
  #4 (permalink)  
Old 11-18-05, 15:13
fredservillon fredservillon is offline
Registered User
 
Join Date: Oct 2005
Posts: 178
Quote:
Originally Posted by sam_h
Hi all. I'm in need of help with this one. (see code below)

The file connects to an access database to populate drop down boxes. This all works fine when tested on my local personal web server. Now i need to get this online but I can't get it to worlk.

I have tried this code;

Code:
var strconnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("FAQS.mdb")
This did not work and all i get is a 500 server error. Can anyone see where im going wrong or where the problem lies? My server can handle asp and my database is in the same folder as my asp file. I can supply the database if anyone needs it.

Many thanks in advance for any help.

Sam.
(P.s. my appologies for the long list of code)


Code:
<%@ language = "Javascript" %>
<%

var strQuestion = "";
if (Request.Querystring("stateChanged") == "true")
{
strQuestion = Request.Form("cboQuestion");
}
var strconnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/testfolder/databases/FAQS.mdb";
%>
<script language=Javascript>
function initControls()
{
populateQuestion();
populateType();
}
function populateQuestion()
{
<%
var rs = Server.CreateObject("ADODB.Recordset");
var sql = "select distinct Question from tblQuestions order by Question"
rs.Open(sql,strconnection);
var n=0;
while (!rs.EOF)
{
var stateID = rs.Fields("Question");
var stateDesc = rs.Fields("Question");
Response.Write("document.frmTest.cboQuestion[" + n + "] = new Option('" + stateDesc+ "','" + stateID + "');");

if (new String(strQuestion).search(stateID) != -1)

Response.Write("document.frmTest.cboQuestion[" + n + "].selected = true;");
rs.MoveNext();
n++;
}
rs.Close();
%>
}

function populateType()
{
<%
if (strQuestion != "")
  {
	var rs2 = Server.CreateObject("ADODB.Recordset");
	var strSql = "select distinct SubQuestion from tblQuestions where Question = '" + strQuestion + "' ";
	rs2.Open(strSql,strconnection);
	var n=1;
	while (!rs2.EOF)
		{
			var strType = rs2.Fields("SubQuestion");
			Response.Write("document.frmTest.cboSubQuestion[" + n + "] = new Option('" + strType + "','" + strType + "');");
			rs2.MoveNext();
			n++;
		}
		rs2.Close();
	}
%>
}
function fillType()
	{
		document.frmTest.action = "contact-sam3.asp?stateChanged=true";
		document.frmTest.submit();
	}
		function saveData()
	{
		document.frmTest.action = "./contact-sam3.asp";
		return true;
	}

</script>

<html>
<head>
<title>Multi Dropdown Selecting Value from one second will Display its corresponding values</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- Fireworks MX Dreamweaver MX target.  Created Tue Aug 19 09:32:36 GMT+0500 (West Asia Standard Time) 2003-->
<script language="javascript">
<!--

function dept_onchange(frmTest) {
	frmTest.submit(); 
}

//-->
</script>

</head>
<body onload = "initControls();" bgcolor="#ffffff" link="#666666" vlink="#666666" alink="#666666" leftmargin="0" topmargin="0">
<table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
  <!-- fwtable fwsrc="index.png" fwbase="default.jpg" fwstyle="Dreamweaver" fwdocid = "742308039" fwnested="1" -->
  <tr>
   <td>
      <table border="0" cellpadding="0" cellspacing="0" width="780">
        <tr> 
          <td>&nbsp;</td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
   <td><table border="0" cellpadding="0" cellspacing="0" width="780">
	  <tr>
	      <td valign="top">
            <table width="220" border="0" cellpadding="0" cellspacing="0" bgcolor="#D6E6F3">
              <tr> 
                <td valign="top" bgcolor="96C2DD"> <strong style="font-weight: 400"> 
                  <font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FFFFFF"> 
                  Question &amp; SubQuestion</font></strong></td>
              </tr>
              <tr> 
                <td valign="top"> 
                  <form name="frmTest" method="post" action="contact-sam3.asp">
                    <table width="220" border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
                      <tr valign="top" bgcolor="#D6E6F3"> 
                        <td height="25" colspan="2" width="220"> 
                          <select name="cboQuestion" onChange="fillType()">
                            <option value="Select Question" selected>Select Question</option>
                          </select>
                        </td>
                      </tr>
                      <tr bgcolor="#D6E6F3"> 
                        <td width="153" valign="top" bgcolor="#D6E6F3"> 
                          <SELECT name=cboSubQuestion LANGUAGE=javascript onchange="return dept_onchange(frmTest)">
						  <option value="Select Question" selected>Select Question</option>
						  </select>
                        </td>
                        <td width="67" bgcolor="#D6E6F3"> 
                          <INPUT TYPE = "Submit" VALUE = "GO>>>>">
                        </td>
                      </tr>
                    </table>
                  </form>
                </td>
              </tr>
            </table>
          </td>
	      <td align="right">&nbsp; </td>
	  </tr>
	</table></td>
  </tr>
</table>
The following was selected : <%=Request.Form ("cboSubQuestion")%>
</body>
</html>

It could be just a syntax error ie, missing ";" at end of your statement here ..

var sql = "select distinct Question from tblQuestions order by Question"

which literaly ended the statement on the next line.
Reply With Quote
  #5 (permalink)  
Old 11-29-05, 15:30
pramsey pramsey is offline
Registered User
 
Join Date: Nov 2005
Posts: 20
For security purposes, your database is in a different directory than your www files, correct? You may want to contact your host to find out the path to your directory. Also, you may want to try a different method of connecting to your database.
Code:
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=THE PATH TO THE DB THAT YOU ARE TRYING TO CONNECT TO.mdb")
__________________
Programming/Web Design
http://eofficeprofessionals.com/forums

Offer solutions-not criticism.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Trackbacks are On
Pingbacks are On
Refbacks are On