ASP


主页 | 上一层 | 编程示例 | 在线考试

 










JavaScript
ASP
JSP
Flash


8.2 ASP技术

8.2.1 ASP语法

8.2.3 在ASP中使用SQL语法示例

8.2.4 ASP中的对象

8.2.5 ASP编程示例

8.2.6 在线考试


 

8.2.1 ASP语法

1.ASP的过程

下面是一个利用VBScript来定义过程的例子:


<html>

<head>

<%

sub vbproc(num1,num2)

response.write(num1*num2)

end sub

%>

</head>

<body>

The result of the calculation is: <%call vbproc(3,4)%>

</body>

</html>


2.JavaScript中的函数定义方法


<%

function jsproc(num1,num2)

{

Response.Write(num1*num2)

}

%>


返回

8.2.3 在ASP中使用SQL语法示例

下面给出的是SQL的语法示例,在需要使用相应的SQL命令的时候,只需要把这些命令拷贝到源代码编辑器中,然后修改其中的相应参数即可。

1、连接数据库


strProvider = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=(将该段文字替换为本地硬盘上数据库的路径);"

Set objConn = server.createobject("ADODB.Connection")
  objConn.Open strProvider


2、DELETE


strCommand = "DELETE FROM Customers WHERE LastName = 'Smith'"

objConn.Execute strCommand


3、SELECT


sql1="select * from online where 姓名='" & name & "' and passwd='" & passwd &"'"

set rs=objConn.execute(sql1)


4、UPDATE


strCommand = "UPDATE online SET 平时1 = '" & score & "' WHERE 姓名 = '" & name & "' "

objConn.Execute strCommand


5、INSERT


strCommand = "INSERT INTO Customers (FirstName, LastName) VALUES ('Jose','Lugo')"

objConn.Execute strCommand 


返回

8.2.4 ASP中的对象

1.Response


<%
response.write"Hello World!"
%>


2.Request


<html>
<body>
<form action="demo_simplereqquery.asp" method="get">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="submit" value="Submit">
</form>
<%
Response.Write(Request.QueryString)
%>
</body>
</html>


3.Application


<%

Application("hello")="Hello!"

Application("name")="Tom."

For i=1 to Application.Contents.Count

Response.Write(x & "=" & Application.Contents(x) & "<br />")

next

%>


4.Session


Session("username")=name



name =Session("username")


5.Server


<%
Set fs = Server.CreateObject("Scripting.FileSystemObject")
Set rs = fs.GetFile(Server.MapPath("demo_lastmodified.asp"))
modified = rs.DateLastModified
%>
该网页的修改时间是: <%response.write(modified)
Set rs = Nothing
Set fs = Nothing
%>


返回

 
  粤ICP备05016703号

如果速度慢,可以尝试访问本站的镜像站点:
北方:http://www.chengzhi.net
南方: http://www.chengzhi.net