某一公司的ASP面试题
来源:风之相随'S BLOG 发布时间:2011-09-15 20:50:20
第一题:ASP中,VBScript的唯一的数据类型是什么?
第二题:在ASP中,VBScript有多种控制程序流程语句,如If…Then, Select… Case,
For … Next, Do … Loop, Exit等语句。请为这五个语句分别写一段使用的代码。
第三题:请看如下代码
<%
TestString="Test"
TestA
TestB
Response.write TestString
Sub TestA()
TestString="TestA"
End Sub
Sub TestB()
Dim TestString
TestString="TestB"
End Sub
%>
这段代码执行后,运行结果是什么?并解释一下为什么?
第四题:在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 ansi<=57) or (ansi=>65 and ansi<=90) or (ansi=>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)&"<br>"
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 "<br>"0D
next
next
第七题:
set rs=ConnTestDB.execute("Select top 100 name,sex from Student order by id,sex")
response.Write "姓名 性别<br>"
while not rs.eof
response.Write rs("name")&" "&rs("sex")&"<br>"
rs.movenext
wend
第八题:
set rs=ConnTestDB.execute("Select name,Chinese,math from Student,Score where StuID=ID")
response.Write "姓名 语文 数学 总成绩<br>"
while not rs.eof
response.Write rs("name")&" "&rs("Chinese")&" "&rs("math")&" "&(rs("Chinese")+rs("math"))&"<br>"
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题的处理方法我个人认为不是很妥当,请各位指点一下还有什么别的方法吗?:)
猜你喜欢
- mysql找不到my.ini文件问题描述刚刚在修改mysql默认配置的时候,发现找不到my.ini文件。按照其他搬运工的说法,打开隐藏的文件
- 本文实例讲述了python求解水仙花数的方法。分享给大家供大家参考。具体如下:一个N位的十进制正整数,如果它的每个位上的数字的N次方的和等于
- 前言众所周知,jquery在我们日常开发中的使用频率非常高,与js相比,我们省去了冗长的获取元素的代码,不用考虑一些麻烦的兼容问题,更加方便
- 这里使用的是mysql Ver 14.14 Distrib 5.6.19, for Linux (i686) using EditLine
- 通常人们使用以下两种方法来执行SQL语句: Set Rs=Conn.Execute(SqlStr) 和&nbs
- MSSQL随机数 MSSQL有一个函数CHAR()是将int(0-255) ASCII代码转换为字符。那我们可以使用下面MS SQL语句,可
- 导读:分析时间序列数据的一种简单而有效的方法就是将时间序列数据可视化在一个图表上,这样我们就可以从中推断出某些假设。本文将以股价数据集为例,
- MySQL批量插入问题在开发项目时,因为有一些旧系统的基础数据需要提前导入,所以我在导入时做了批量导入操作 ,但是因为MySQL中的一次可接
- 本文实例讲述了Python简单格式化时间的方法,分享给大家供大家参考,具体如下:walker经常用到当前时间和相对时间,用来统计程序执行的效
- 首先得有一个Scrapy项目,我在Desktop上新建一个Scrapy的项目叫test,在Desktop目录打开命令行,键入命令:scrap
- 数据标准化(归一化)处理是数据挖掘的一项基础工作,不同评价指标往往具有不同的量纲和量纲单位,这样的情况会影响到数据分析的结果,为了消除指标之
- Neo4j是一款开源图数据库,Py2neo提供了使用Python语言访问Neo4j的接口。本文介绍了使用Py2neo的NodeMatcher
- 本文研究的主要是Python使用requests发送POST请求的相关内容,具体介绍如下。一个http请求包括三个部分,为别为请求行,请求报
- 在 asp 应用中,经常用到 Session 对象来保存用户临时私有数据,而 asp 的 Session 对象是依赖于浏览器的 Cookie
- 环境:Python+keras,后端为Tensorflow训练集:MNIST对于如何训练一个识别手写数字的神经网络,网上资源十分丰富,并且能
- 这是一个特别简单的用原生js实现的一个小鸟游戏,比较简单,适合新手练习。html结构<div id="game"&
- 一.实现思路本文讲解如何使用python实现一个简单的模板引擎, 支持传入变量, 使用if判断和for循环语句, 最终能达到下面这样的效果:
- 前言:线性回归模型属于经典的统计学模型,该模型的应用场景是根据已知的变量(即自变量)来预测某个连续的数值变量(即因变量)。例如餐厅根据媒体的
- 首先这个bak文件是SQL数据库的备份文件,要使用SQL恢复然后就可以查询了找到需要的文件注意解压出来有7GB+1、下载SQL server
- 前言在日常开发中,我们往往会将 JSON 解析成对应的结构体,反之也会将结构体转成 JSON。接下来本文会通过 JSON 包的两个函数,来介