ASP面试试题及答案

时间:2024-08-18 23:18:00 学人智库 我要投稿
  • 相关推荐

ASP面试试题及答案

第一题:ASp中,VBScript的唯一的数据类型是什么?

ASP面试试题及答案

第二题:在ASp中,VBScript有多种控制程序流程语句,如If…Then, Select… Case,

For … Next, Do … Loop, Exit等语句。请为这五个语句分别写一段使用的代码。

第三题:请看如下代码

这段代码执行后,运行结果是什么?并解释一下为什么?

第四题:在ASp中,Server中有一个方法是URLEncode(string)

如: response.write Server.URLEncode("Test.ASp?TestNum=100&TestStr=你好")

结果输出: Test%2EASp%3FTestNum%3D100%26TestStr%3D%C4%E3%BA%C3

在ASp中,有ASC(String),Hex(Number),Mid(String,start,[,length])这三个可能用

到的函数,如果是三个函数的用法

如:

ASC("A")=65,ASC("你")= -15133

Hex(65)="41",Hex(-15133)="C4E3"

Mid("hello",2,1)="e", mid("this is test!",9,2)="te"

现在要求编写编码函数Function TestEncode(SourceString),及一个解码函数

Function TestDecode(CodeString)。TestEncode(SourceString)是将SourceString

串中非字母且非汉字且非数字的字符转换为对应Ansi编码的十六进制编码!

如:

TestEncode("Test.ASp?TestNum=100&TestStr=你好")=

"Test%2EASp%3FTestNum%3D100%26TestStr%3D你好"

而TestDecode(CodeString)是将编码的串还原,是TestEncode的逆函数。

第五题:

编写一个星期的函数GetWeek(aDate)

返回"星期一、星期二、星期三..."

第六题:

用ASp输出九九乘法口决表的网页

输出如下:

1*1=1

1*2=2 2*2=4

1*3=3 2*3=6 3*3=9

...

要求编写一个完整的ASp文件

第七题到第九题

已知SQL Server数据库的有一个数据库TestDB,学生表结构如下:

表名:Student

字段名 类型 说明

id int 自增1

name var16)

sex 1) F表示女性,M表示男性

... ...

已知已经定义了ADODB.Connection对象ConnTestDB已连接了上述的TestDB数据库

可以在以后的测试题中直接引用该对象.

第七题:

编写ASp代码,将Student中的人的姓名及性别列出来,并给统计学生人数如下:

姓名 性别

张三 男

李四 男

王五 女

... ...

总共有100个学生

第八题:

在上述数据库中,有一个表存放学生的得分的,结构如下:

表名:Score

字段名 类型 说明

StuID int 学生的ID值,关系是:Score.StuID=Student.ID

Chinese int

math int

要求输出内容:

姓名 语文 数学 总成绩

张三 60 100 160

...

请编写实现上述功的ASp代码

第九题:

已知:

某一学生:陈六,男,语文80分,数学60分,现要求编写ASp代码

将该学的数据插入数据库中,分别插入到上述的两个表Student,Score表中。

解答:

第一题:Variant

第二题:

dim x,y

if x="" then

x=1

end if

select case x

case 1

x=x+1

case 2

x=x+2

end select

for y=0 to x

response.write y

if y=2 then exit for

next

do

x=x+1

if x=4 then exit do

loop while x<5

第三题:

运行结果是:testA

原因是:testA所附值的是一个全局变量TestString

testB因为有Dim TestString这句定义,所以它所附值的只是一个局部变量。

第四题:

dim str

str="Test.ASp?TestNum=100&amp;TestStr=你好"

function TestEncode(f_Str)

0Adim str_len

dim for_x

dim char

dim ansi

str_len=len(f_Str)

for for_x=1 to str_len

char=mid(f_Str,for_x,1)

ansi=char)

if (ansi=>48 and ansi<=57) or="">65 and ansi<=90) or="">97 and ansi<=122) or (ansi<0 or="" ansi="">225) then

TestEncode=TestEncode&char

else

TestEncode=TestEncode&""&cstr(Hex(ansi))

end if

next

end function

function TestDecode(f_Str)

0Adim str_len

dim for_x

dim char

dim ansi

str_len=len(f_Str)

for for_x=1 to str_len

char=mid(f_Str,for_x,1)

if char="" then

ansi=mid(f_Str,for_x+1,2)

TestDecode=TestDecode&chr(clng("&H"&ansi))

for_x=for_x+2

else

TestDecode=TestDecode&char

end if

next

end function

response.Write TestEncode(str)&"

"

response.Write TestDecode(TestEncode(str))

第五题:

function GetWeek(aDate)

if isdate(aDate) then

GetWeek=weekdayname(WeekDay(aDate))

end if

end function

response.Write GetWeek("2002/1/3")

第六题:

dim x,y

for x=1 to 9

for y=1 to x

response.Write y&"*"&x&"="&x*y&" "

if x=y then response.Write "

"

next

next

第七题:

set rs=ConnTestDB.execute("Select top 100 name,sex from Student order by id,sex")

response.Write "姓名    性别

"

while not rs.eof

response.Write rs("name")&"    "&rs("sex")&"

"

rs.movenext

wend

第八题:

set rs=ConnTestDB.execute("Select name,Chinese,math from Student,Score where StuID=ID")

response.Write "姓名  语文  数学  总成绩

"

while not rs.eof

response.Write rs("name")&"  "&rs("Chinese")&"  "&rs("math")&"  "&(rs("Chinese")+rs("math"))&"

"

rs.movenext

wend

第九题:

dim StrudentID,StrudentName,Strudentsex

StrudentName="陈六"

Strudentsex="男"

S_Chinese=80

S_math=60

Function yhsql(data)

yhsql=""&replace(data,"","\")&""

End Function

ConnTestDB.execute " into Student (name,sex) value ("26yhsql(StrudentName)&","&yhsql(Strudentsex)&") "

StrudentID=ConnTestDB.execute("select max(id) as sid from Strdent where name="&yhsql(StrudentName))("sid")

ConnTestDB.execute " into Score (StuID,Chinese,math) value ("&S_Chinese&","&S_math&") "

附:

第7题

asp程序优化之:对象变量

当遍历记录集时,一个保证能提高性能的方法是使用对象变量指向集合中的成员。例如,考虑下面的遍历含有Authors表的记录集的例子。

While Not rsAuthors.EOF

Response.Write rsAuthors("au_fname") & " " & _

rsAuthors("au_lname") & "

"

rsAuthors.MoveNext

Wend

可以用下面的方法加速代码执行,同时使其更易于理解。

Set FirstName = rsAuthors("au_fname")

Set LastName = rsAuthors("au_lname")

While Not rsAuthors.EOF

Response.Write FirstName & " " & LastName & "

"

rsAuthors.MoveNext

Wend

这里使用了两个变量,并指向记录集的Fidds集合中的特定字段(记住,Fidds集合是缺省的集合)。因为这里建立了一个对象的引用,所以可以使用对象变量而不是实际的变量,这意味着脚本引擎的工作减少了,因为在集合中进行索引的次数变少了。

[ASP面试试题及答案]

【ASP面试试题及答案】相关文章:

Asp.Net 面试题09-28

ASP.NET面试试题集锦10-06

面试试题及答案10-02

外企面试的经典面试试题及答案07-27

java面试题及答案10-03

经典java面试题及答案06-11

客服面试试题及答案10-10

小升初面试试题及答案08-15

护士面试试题及答案10-24

银行面试试题及答案07-04