假如一个数据库的表中有“学号”和“姓名”两个字段,如果想在输入表单中输入学号后鼠标离开时自动到数据库的表中去查找相应的姓名并且在姓名的框中显示出来,请问应如何编写程序。
前提条件是每页显示5组(或更多)组表单框,为了使代码简化,采用数组及FOR循环生成表单,代码如下:
<FORM Name="form1" Method="Post" Action="">
<%
dim XueHao(5),XinMing(5)
FOR I=0 TO 4
%>
学号:<INPUT TYPE="Text" NAME="XueHao(<%=I%>)" OnBlur="....">
姓名:<INPUT TYPE="Text" NAME="XinMing(<%=I%>)">
<%Next%>
</FORM>
前提条件是每页显示5组(或更多)组表单框,为了使代码简化,采用数组及FOR循环生成表单,代码如下:
<FORM Name="form1" Method="Post" Action="">
<%
dim XueHao(5),XinMing(5)
FOR I=0 TO 4
%>
学号:<INPUT TYPE="Text" NAME="XueHao(<%=I%>)" OnBlur="....">
姓名:<INPUT TYPE="Text" NAME="XinMing(<%=I%>)">
<%Next%>
</FORM>
解决方案 »
- CFileDialog类获取所有文件名时返回为空的问题,求教
- error LNK2001: unresolved external symbol "int __cdecl GetToValidEdge(class CSubItem *,unsigned int,unsigned int)"
- ------------大家觉得JAVA和VC++哪个难?
- 有没有办法用程序把ADSL保存的账号/密码读出来?
- 如何得知其他应用程序打开的串口的设置情况,比如说波特率,数据位和校验位等信息
- VC中使用动态DLL编译的程序能正常运程,使用静态DLL编译的程序不能正常运行?
- 菜鸟问题:请问VC中String Table里的字符串儿是干什么用的?字符串变量的值是如何定义的?
- 修改IP
- 关于IE中添加菜单项
- 怎样得到金山词霸所提供的单词
- 一个很简单的问题,请指点
- 我的VB和VC++为什么在我的机器上做不上呢?
----------------------------
<html>
<head>
<title>This is the testing page about how to use the database in ASP!</title>
</head>
<body bgcolor="#BBBBFF">
<center>
<font color="blue">
user information for the login the sqlserver2000 and oracle9i<br>
-------------------------------------------<br>
</font>
<form action="insert.asp" method="post">
name: <input type="text" name="name"><br>
TelNo:<input type="text" name="telno"><br>
PhoNo:<input type="text" name="phono"><br>
Email:<input type="text" name="email"><br>
Address:<input type="text" name="address"><br>
<input type="submit" value="submit" name="submit">
<input type="reset" value="reset" name="reset">
</form>
<a href="http://127.0.0.1:1996/use_db/oracle_asp.asp"><font size=5 >test oracle database</font></a>
</center>
</body>
</html>
-----------------------------------file:insert.asp
----------------------------------
<%
name=request.form("name")
telno=request.form("telno")
phono=request.form("phono")
email=request.form("email")
address=request.form("address")
set conn=Server.CreateObject("ADODB.Connection")
strDSN="DSN=Test_ASP;UID=psusong;PWD=psusong"
conn.open strDSN
SQL="INSERT INTO userinfo(name,TelNo,PhoNo,Email,Address)"
SQL=SQL & " VALUES('" & name & "','" & telno & "','" & phono & "','" & email & "','" & address & "')"
conn.Execute(SQL)%>
<%
response.redirect "show.asp"
%>
----------------------------------file:show.asp
----------------------------------
<%strDSN="DSN=Test_ASP;UID=psusong;PWD=psusong"
set conn=createobject("ADODB.Connection")
conn.open strDSN
SQL="SELECT * FROM userinfo"
SET rs=conn.Execute(SQL)%>
<body bgcolor="#BBBBFF">
name TelNO PhoNo Email  Address <br>
<%do while not rs.eof %>
<font color="Red">
<%=rs("name")%>
</font>
<%=rs("TelNo")%>
<%=rs("PhoNo")%>
<%=rs("Email")%>
<font color="blue">
<%=rs("Address")%>
</font><br>
<% rs.movenext
loop%>
</body>
------------------------file:oracle_asp.asp
------------------------
<%Set OraSession=CreateObject("OracleInProcServer.XOraSession")
Set OraDatabase=OraSession.DbOpenDatabase("itanynj","scott/psusong",0)
Set rs=OraDatabase.CreateDynaset("select * from EMP",0)
%>
<body bgcolor="#BBBBFF">
<center>
<font color="red" size=5>
empno ename hiredate job<br>
</font>
-----------------------------------------<br>
<% DO WHILE NOT rs.eof%>
<%=rs("empno")%>
 
<font color="blue">
<%=rs("ename")%>
</font>
 
<%=rs("hiredate")%>
 
<font color="blue">
<%=rs("JOB")%>
</font>
<br>
<%rs.movenext
loop%>
-----------------------------------------<br>
<font color="blue">
This is the example of testing Active Server Page by oracle database!<br>
This is the example "SELECT * FROM EMP" from the user:scott/tiger<br>
Set OraSession=CreateObject("OracleInProcServer.XOraSession")<br>
Set OraDatabase=OraSession.DbOpenDatabase("database_name","scott/tiger",0)<br>
Set rs=OraDatabase.CreateDynaset("select * from EMP",0)
</center>
</body>
-------------------------
说明:
IIS中建立了一个web站点端口号:1996
建立了一个SQL server2000的数据库表userinfo
其中有字段:id ,name,TelNo,PhoNo,Email,Address
在程序中也测试了oracle地联结方式!