一个兼职asp程序员的测试题
1
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
2
<%
3
Dim conn, connstr, db
4![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
5
db = "abc.mdb"
6
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:DataBase Password=51888888;Data Source=" & Server.MapPath("" & db & "")
7
Set conn=Server.Createobject("ADODB.CONNECTION")
8
conn.Open connstr
9![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
10
%>
11
<%
12
'--
13
'调用方法:
14
'<script src="get.asp?n=调用的条数&tlen=22&name=类别名称&isshow=1"><'/script>
15![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
16
'说明:
17
'需制作调用文章评论的一个页面get.asp,页面中获取参数,并写一个函数,函数通过获取的参数,以js形式输出内容,输出内容样式见“显示样式”。
18![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
19
'表名:pinglun
20
'字段名:id(自动编号),title(标题),name(类别名称),newsid(文章id),adddate(添加时间)
21![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
22
'参数说明:
23
'n 调用的条数,默认为10。为空或0则为10条。
24
'tlen 标题显示长度,默认为22个字符。为空或0则为22个字符。
25
'name 类别名称
26
'newsid 文章ID号,可以调用多个,各个之间使用"|"隔开,比如:newsid=1170|1117|2004
27
'isshow 是否显示添加时间,1为显示。
28![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
29
'显示样式:
30
'.标题(添加时间)
31
'.标题(添加时间)
32
'.标题(添加时间)
33
'.标题(添加时间)
34
'.标题(添加时间)
35
'.标题(添加时间)
36
'.标题(添加时间)
37
'.标题(添加时间)
38
'.标题(添加时间)
39
'.标题(添加时间)
40
%>
41
<%
42
Function GetLeng(str,length)
43
IF IsNull(str) or IsEmpty(str) Then
44
GetLeng = str
45
Else
46
GetLeng = Left(str,length)
47
End IF
48
End Function
49
Dim rs,rCmd,strSql,pageSize,tLen,tName,newsID,isShow,outHtml:pageSize=10:tLen=22:isShow = Request.QueryString("isshow")
50![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
51
IF IsNumeric(Request.QueryString("n")) Then
52
pageSize = Cint(Request.QueryString("n"))
53
IF pageSize < 1 Then pageSize = 10
54
End IF
55![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
56
tName = Request.QueryString("name")
57
IF IsNull(tName) or IsEmpty(tName) Then
58
tName = ""
59
End IF
60![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
61
newsID = Request.QueryString("newsid")
62
IF (Not IsNull(newsID) And Not IsEmpty(newsID)) Then
63
newsID = Replace(Replace(Replace(newsID,"'","")," ",""),"|",",")
64
End IF
65![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
66
IF IsNumeric(Request.QueryString("tlen")) Then
67
tLen = Cint(Request.QueryString("tlen"))
68
IF tLen<1 Then tLen = 22
69
End IF
70
'假设数据连接已经做好为conn
71
Set rCmd = Server.CreateObject("ADODB.Command")
72
rCmd.ActiveConnection = conn
73
rCmd.CommandType = 1
74
rCmd.Prepared = true
75
rCmd.Parameters.Append(rCmd.CreateParameter("@tName",200,1,100,tName))
76
77
strSql = "select Top " & pageSize & " [id],[title],[adddate] from [pinglun] where name=@tName "
78![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
79
IF Not(IsNull(newsID) or IsEmpty(newsID)) Then
80
strSql = strSql & " and newsid in(" & newsID & ")"
81
End IF
82
Response.Write(strSql)
83
rCmd.CommandText = strSql
84
Set rs = rCmd.Execute()
85
Dim i:i=0
86
While(Not rs.EOF And i < pageSize)
87
outHtml = outHtml & "<li>" & GetLeng(rs("title"),tLen)
88
IF isShow = "1" Then
89
outHtml = outHtml & "(" & rs("adddate") & ")"
90
End IF
91
outHtml = outHtml & "</li>"
92
i=i+1
93
rs.MoveNext
94
Wend
95
with Response
96
.Write("var outHtml = ""<ul>"";")
97
.Write("outHtml +=""" & Replace(outHtml,"""","\""") & """;")
98
.Write("outHtml += ""</ul>"";")
99
.Write("document.write(outHtml);")
100
End With
101
%>
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
5
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
6
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
7
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
8
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
9
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
10
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
11
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
12
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
13
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
14
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
15
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
16
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
17
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
18
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
19
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
20
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
21
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
22
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
23
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
24
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
25
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
26
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
27
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
28
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
29
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
30
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
31
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
32
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
33
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
34
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
35
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
36
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
37
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
38
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
39
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
40
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
41
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
42
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
43
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
44
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
45
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
46
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
47
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
48
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
49
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
50
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
51
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
52
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
53
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
54
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
55
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
56
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
57
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
58
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
59
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
60
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
61
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
62
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
63
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
64
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
65
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
66
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
67
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
68
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
69
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
70
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
71
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
72
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
73
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
74
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
75
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
76
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
77
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
78
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
79
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
80
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
81
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
82
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
83
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
84
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
85
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
86
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
87
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
88
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
89
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
90
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
91
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
92
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
93
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
94
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
95
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
96
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
97
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
98
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
99
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
100
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
101
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
决不做一个程序代码的写手.