国内程序转移至国外空间后,无法连接ACCESS数据库。已使用相对地址。请帮助。非常感谢。
fkys 2008-10-08 01:13:12 国内空间的asp代码正常,转移到国外空间(Lunarpages)后,无法连接数据库。
我弄了2个测试页。在本机(WINXP+IIS5)可以运行。但是在国外空间上(www.cjiitcn.net/cjmit/search.asp)
请您帮助。非常感谢。
本机测试查询页面:(search.asp 和 result.asp放在c:\inetpub\wwwroot\code下。数据库文件cjmit.mdb放在c:\inetpub\wwwroot\code\data下)
服务器上的测试文件和数据库文件关系与本机相同:search.asp和result.asp放在 根目录\httpdocs\cjmit下,cjmit.mdb放在 根目录\httpdocs\cjmit\data下。
查询页面:
search.asp
=============
'=============JS代码判断是否为空字符串
<script language="JavaScript">
<!--
function checkinput()
{
if (document.form1.gh.value=="")
{
alert("Please input your number");
document.form1.gh.focus();
return false;
}
return true;
}
-->
</script>
'======================查询表单
</font> </h2>
<h2>
<form name="form1" action="result.asp" method="get" onsubmit="return checkinput()" >
<span class="9p">Please input you number: </span> <font face="隶书" color="#0000FF">
<input type="text" name="gh">
<input type="submit" name="Submit" value="find out">
</font>
</form>
</h2>
<h2> <br>
</h2>
</table>
=====================
结果页面:
result.asp
====================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
'===============连接数据库==========
<%
mp="data/cjmit.mdb"
set db=server.createObject("ADODB.connection")
db.open "Provider=Microsoft.Jet.OLEDB.4.0;"& _
"Data Source=" & Server.MapPath(mp)
sql="select * from gj where gh="&request("gh")&""
set rs=db.execute(sql)
%>
'===============查询数据库===========
<% if rs.eof then %>
</h2>
<h3 align="center"> <font face="宋体" color="#000000">
<% response.write "Sorry. NO such number."%>
</font> </h3>
<% else %>
<table width="91%" border="2" align="center">
<tr>
<td width="56%" height="21"> <b>Number </b>: <%=rs("gh").value%> </td>
<td width="44%" height="21"> <b>Name </b>: <%=rs("zz").value%> </td>
</tr>
<tr>
<td colspan="2"> <b>Unit </b>: <%=rs("dw").value%> </td>
</tr>
<tr>
<td colspan="2"> <b>Topic </b>: <%=rs("tm").value%> </td>
</tr>
<tr>
<td width="56%" height="23"> <b>Status </b>: <%=rs("zt").value%> </td>
<td width="44%" height="23"> <b>Sum1 </b>: <%=rs("sgf").value%>元 </td>
</tr>
<tr>
<td width="56%" height="23"> <b>Data1 </b>: <%=rs("sgfdz").value%> </td>
<td width="44%" height="23"> <b>Data2 </b>: <%=rs("bmfsfrq").value%> </td>
</tr>
<tr>
<td width="56%" height="23"> <b>Sum2 </b>: <%=rs("bmf").value%>元 </td>
<td width="44%" height="23"> <b>Data3 </b>: <%=rs("bmfdzsj").value%> </td>
</tr>
<% end if %>
</table>
<br>
</body>
</html>
==========================
在国外空间输入数字后的错误:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator to inform of the time the error occurred and of anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
--------------------------------------------------------------------------------
Web Server at cjiitcn.net