学习啦>创业指南>职场>面试题>

有哪些ASP面试题

书荣分享

  ASP即Active Server Pages,是MicroSoft公司开发的服务器端脚本环境,可用来创建动态交互式网页并建立强大的web应用程序。下面是学习啦小编为你整理的ASP面试题,希望对你有所帮助!


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

  第二题:在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 varchar(16)

  sex char(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&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=asc(char)

  if (ansi=>48 and ansi65 and ansi97 and ansi225) 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 “”0D

  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 “insert 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 “insert into Score (StuID,Chinese,math) value (“&S_Chinese&”,”&S_math&”) ”

  —————————————————————-

  第7到9题没有经过测试,可能会有语法上的错误。

  还有,第9题的处理方法我个人认为不是很妥当,请各位指点一下还有什么别的方法吗?:)


面试题相关文章:

1.求职面试题目及答案大全

2.经典面试题

3.竞聘上岗面试题及答案

4.抗压能力面试题及参考答案

5.经典情景面试题及参考答案

    4064187