📄 基于asp的编程常见问题.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0047)http://www6.163.com/it/item/0,2186,5726,00.html -->
<!-- Vignette StoryServer 4 Tue Feb 26 14:20:45 2002 --><HTML><HEAD><TITLE>IT</TITLE>
<META content="text/html; charset=gb2312" http-equiv=Content-Type><!-- Vignette StoryServer 4 Fri Jun 30 09:33:27 2000 -->
<STYLE type=text/css>P {
FONT-FAMILY: 宋体; FONT-SIZE: 9pt; LINE-HEIGHT: 14pt
}
DIV {
FONT-FAMILY: 宋体; FONT-SIZE: 9pt; LINE-HEIGHT: 14pt
}
.p1 {
FONT-FAMILY: 宋体; FONT-SIZE: 9pt
}
.p2 {
FONT-FAMILY: 宋体; FONT-SIZE: 9pt; LINE-HEIGHT: 14pt
}
.p3 {
FONT-FAMILY: 宋体; FONT-SIZE: 14px
}
.p4 {
FONT-FAMILY: 宋体; FONT-SIZE: 14px; LINE-HEIGHT: 14pt
}
.p5 {
FONT-SIZE: 1pt
}
.headtable {
FONT-SIZE: 9pt
}
A:hover {
COLOR: red
}
A.t1:visited {
COLOR: red
}
</STYLE>
<META content="MSHTML 5.00.2919.6307" name=GENERATOR></HEAD>
<BODY aLink=#ff0000 bgColor=#ffffff link=#383098 text=#000000 topMargin=0
vLink=#336699><!-- Vignette StoryServer 4 Thu Nov 23 09:20:16 2000 -->
<TABLE border=0 cellPadding=0 cellSpacing=0 width=750>
<TBODY>
<TR>
<TD class=headtable height=54 width=200><A href="http://www.163.com/"><IMG
border=0 height=54 src="IT6.files/163logo.gif" width=160></A> <BR> <A
class=headtable href="http://freemail.yeah.net/"><FONT
color=#ff0000>赶快申请8M永久免费电子邮箱</FONT></A><BR> <A class=headtable
href="http://bj4.netease.com/feedback/jobs.html">网易公司诚聘英才</A> </A></TD>
<TD align=right class=headtable width=540><FONT
color=#ff0000>>></FONT><A
href="http://www.163.com/index.html">返回首页</A> <A
href="http://news.163.com/index.html"><FONT color=#ff0000>焦点新闻</FONT></A>
<A href="http://mall.163.com/">网易商城</A> <A
href="http://bj.163.com/">网易社区</A> <A
href="http://www.yeah.net/index.html">搜索引擎</A> <A
href="http://freemail.yeah.net/">免费邮件</A> <A
href="http://auctions.163.com/">网上拍卖</A> <A
href="http://www.163.com/serve/">个人服务</A><BR><!--Here is ad beginning.--><IFRAME
frameBorder=0 height=60 marginHeight=0 marginWidth=0 scrolling=no
src="IT6.files/site=www.163.htm" width=468
BORDERCOLOR="#000000"><SCRIPT LANGUAGE="JavaScript1.1" SRC=http://adserver.163.com/js.ng/site=www.163.com&category=it&type=banner></SCRIPT><NOSCRIPT><A HREF=http://ad1.163.com/click.ng/Params.richmedia=yes&site=www.163.com&category=it&type=banner><IMG SRC=http://ad1.163.com/image.ng/Params.richmedia=yes&site=www.163.com&category=it&type=banner></A></NOSCRIPT></IFRAME><!--Here is ad end.--></TD></TR></TBODY></TABLE>
<TABLE border=0 cellPadding=0 cellSpacing=0 height=10 width=740>
<TBODY>
<TR>
<TD><IMG border=0 height=0 src="IT6.files/dot.gif" width=0></TR></TBODY></TABLE>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=750>
<TBODY>
<TR>
<TD width=70>
<TABLE border=0 cellPadding=0 cellSpacing=1 width="100%">
<TBODY>
<TR align=middle bgColor=#eeeeee>
<TD class=p1 height=20><A href="http://news.163.com/"><FONT
color=#000000>新闻</FONT></A></TD>
<TD class=p1><A href="http://sports.163.com/"><FONT
color=#000000>体育</FONT></A></TD></TR></TBODY></TABLE></TD>
<TD align=middle bgColor=#0036b2 class=p1 height=20 width=35><A
href="http://it.163.com/"><FONT color=#ffffff>电脑</FONT></A></TD>
<TD width=490>
<TABLE border=0 cellPadding=0 cellSpacing=1 width="100%">
<TBODY>
<TR align=middle bgColor=#eeeeee>
<TD class=p1 height=20><A href="http://game.163.com/"><FONT
color=#000000>游戏</FONT></A></TD>
<TD class=p1><A href="http://stock.163.com/"><FONT
color=#000000>财经</FONT></A></TD>
<TD class=p1><A href="http://house.163.com/"><FONT
color=#000000>房产</FONT></A></TD>
<TD class=p1><A href="http://culture.163.com/"><FONT
color=#000000>文化</FONT></A></TD>
<TD class=p1><A href="http://lady.163.com/"><FONT
color=#000000>女性</FONT></A></TD>
<TD class=p1><A href="http://movie.163.com/"><FONT
color=#000000>影视</FONT></A></TD>
<TD class=p1><A href="http://music.163.com/"><FONT
color=#000000>音乐</FONT></A></TD>
<TD class=p1><A href="http://life.163.com/"><FONT
color=#000000>生活</FONT></A></TD>
<TD class=p1><A href="http://travel.163.com/"><FONT
color=#000000>旅游</FONT></A></TD>
<TD class=p1><A href="http://science.163.com/"><FONT
color=#000000>科学</FONT></A></TD>
<TD class=p1><A href="http://health.163.com/"><FONT
color=#000000>健康</FONT></A></TD>
<TD class=p1><A href="http://jobs.163.com/"><FONT
color=#000000>职业</FONT></A></TD>
<TD class=p1><A href="http://education.163.com/"><FONT
color=#000000>教育</FONT></A></TD>
<TD class=p1><A href="http://spicy.163.com/"><FONT
color=#000000>新辣</FONT></A></TD></TR></TBODY></TABLE></TD><!--picture nav--><!--end picturenav-->
<TD align=right class=p1 vAlign=bottom width=155><FONT
color=#ff0000></FONT></TD></TR></TBODY></TABLE>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=750>
<TBODY>
<TR>
<TD bgColor=#0036b2><SPACER height="1" type="block"></TR></TBODY></TABLE>
<TABLE>
<TBODY>
<TR>
<TD align=middle class=p1><A
href="http://all.163.com/it/pcdigest/index.htm">PCD个人网络手册</A> <A
href="http://www.163.com/it/item/0,2186,7448,00.html">Intel技术专题</A> <A
href="http://topsoft.163.com/software/">热门软件排行榜</A> <A
href="http://mobile.163.com/"><FONT color=red>手机站</FONT>全新改版</A> <A
href="http://all.163.com/it/popunet/study/10-1.htm">上网享受再教育</A> <A
href="http://gz.163.com/it2.htm">IT易:电脑频道广东版</A> <A
href="http://www.eshop.com.cn/">eNet导购专家</A> <A
href="http://all.163.com/it/hardbase/index.htm">硬件资料库</A> </TD></TR>
<TR>
<TD bgColor=#0036b2 class=p5 height=2 width=750>.</TD></TR>
<TR>
<TD height=4></TR></TBODY></TABLE>
<TABLE align=left border=0 cellPadding=0 cellSpacing=0 width=0>
<TBODY>
<TR>
<TD></TR></TBODY></TABLE>
<TABLE align=left border=0 cellPadding=4 cellSpacing=0 width=591>
<TBODY>
<TR>
<TD class=p2><A href="http://www6.163.com/it/index/0,2182,,00.html"><FONT
color=red>IT</FONT></A>>>><A
href="http://www6.163.com/it/category/0,2197,3,00.html"><FONT
color=red>软件时空</FONT></A>>>><A
href="http://www6.163.com/it/subcategory/0,2200,14,00.html"><FONT
color=red>编程指南</FONT></A>>>><FONT color=red>具体文章</FONT> </TD></TR>
<TR>
<TD align=middle class=p3 height=30><B>基于ASP的编程常见问题</B>
<P align=center>(05/10/2000)</P></TD></TR>
<TR>
<TD class=p2 width=591>
<P
class=p3> 基于ASP技术开发Internet/Intranet上的MIS系统是非常方便的,首先是它借用了ADO技术和概念,同时通过ODBC访问数据库,达到了充分的灵活性和多平台性,另外,由于ASP利用VBS和JS脚本语言,也保证大多数开发者很快进入开发过程,减少了学习的过程。<BR> 但是,由于ASP是基于Internet/Intranet方式的,它和传统的C/S结构毕竟有所不同,这样在开发中也要注意一些细节问题。本文讲述常见的一些问题,并给出解决方法。
<P>问题描述</P>
<P><B>A.
无法正确运行ASP</B><BR><BR> 当我们建立了一个ASP文件,并且符合语法时,通过浏览器输入以下地址,或通过资源管理器打开浏览:<BR>c:\inetpub\wwwroot\a.asp<BR>将出现无法运行的错误,并提示权限不对或文件无法访问,原因是,ASP文件首先要求站点是具备“执行(脚本)”属性的;然后要求按照URL格式输入地址,而不是DOS格式,所以,请改正这两个错误。</P>
<P><B>B.
程序移动位置后,无法访问数据库</B><BR><BR> 这种错误首先在ODBC,如果ODBC数据源设置正确,那么需要注意ASP中打开数据库的命令:Conn.Open
的参数是否正确。如果正确,则需要注意是否使用了global.asa文件,该文件是ASP连接数据库的配置文件,该文件内容如下:<BR><SCRIPT
LANGUAGE="VBScript" RUNAT="Server"><BR>'You can add special event
handlers in this file that will get run automatically when special Active
Server Pages events<BR>'occur. To create these handlers, just create a
subroutine with a name from the list below that corresponds to the
event<BR>'you want to use. For example, to create an event handler for
Session_OnStart, you would put the following code into this<BR>'file
(without the comments):<BR>'EventName Description<BR>'Session_OnStart Runs
the first time a user runs any page in your application<BR>'Session_OnEnd
Runs when a user's session times out or quits your
application<BR>'Application_OnStart Runs once when the first page of your
application is run for the first time by any user<BR>'Application_OnEnd
Runs once when the web server shuts down</P>
<P></SCRIPT><BR><SCRIPT LANGUAGE=VBScript RUNAT=Server><BR>Sub
Session_OnStart<BR>'==Visual InterDev Generated - DataConnection
startspan==<BR>'--Project Data
Connection<BR>Session("Customers_ConnectionString")="DRIVER={SQL
Server};SERVER=(local);UID=sa;PWD=;APP=Microsoft(R)Developer
Studio;WSID=GREGLEAK;DATABASE=Customers"<BR>Session("Customers_ConnectionTimeout")
= 15<BR>Session("Customers_CommandTimeout") =
30<BR>Session("Customers_RuntimeUserName") =
"sa"<BR>Session("Customers_RuntimePassword") = ""<BR>'==Visual InterDev
Generated - DataConnection endspan==<BR>End
Sub<BR></SCRIPT><BR>要注意其中的DSN,其中SERVER后一定是数据库服务器名称,如果该处不正确,需要改正。另外是UID和PWD是否正确;还有,如果OPEN命令使用了SESSION,则需要注意<BR>Session("Customers_RuntimeUserName")
= "sa"<BR>Session("Customers_RuntimePassword") = ""<BR>是否正确。</P>
<P><B>C.
RUNAT使用问题</B><BR><BR> 在脚本语法中,有RUNAT参数,表示该脚本是运行在服务器上还是客户机上。如果有RUNAT=SERVER则脚本运行在服务器上,由ASP解释程序来解释执行,并将结果传递给WWW服务器;否则就是运行在客户机上,由浏览器的脚本虚拟机解释执行,这时,和一般的脚本没有区别。所以,一定要注意ASP语法中的命令,如:REQUEST,QUERYSTRING,WRITE等命令或对象必须在具备RUNAT参数的脚本运行;而访问HTML的FORM对象的脚本一定没有RUNAT参数,因为HTML的FORM是客户机方面的对象,服务器无法访问。</P>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -