asp程序填空
ASP程序是,向数据库插入记录,并显示记录。数据库名KS.mdb中有一个学生成绩表CJ(字段:学号text,姓名text,成绩int)asp程序文件和数据库KS.mdb在...
ASP程序是,向数据库插入记录,并显示记录。数据库名KS.mdb 中有一个学生成绩表 CJ(字段:学号 text,姓名 text,成绩 int)asp程序文件和数据库KS.mdb在同一目录。
<%@ Language=“VBScript” %>
<html>
<body>
<form Method=“post” action=““>
学号<input type=“text” size=6 name=“xh”>
姓名<input type=“text” size=6 name=“xm”>
成绩<input type=“text”“ size=6 name=“cj”>
<input type=“submit” value=“提交”>
<input type=“reset” value=“重置”>
</FORM>
<% if request.form(“xh”)<>““ then
Set cn = Server.CreateObject(“ADODB.Connection”)
Conn= ( )
cn.Open conn
sql=“insert into cj(学号,姓名,成绩) Values(‘“&request.form(“xh”)&”’,’”& request.form(“xm”)&”’,” request.form(“cj”)&”)”
( )sql=“select * form cj”
call q(sql) %>
<% sub q(sql) ‘显示记录的过程
set rstemp= ( )
howmanyfields=rstemp.fields.count-1%>
<table border=1><tr>
<%for i=0 to howmanyfields%>
<td><b>
<%= ( )%>
</B></TD>
<% next %>
</tr>
<%Do while ( ) %>
<%for i=0 to howmanyfields%>
<td><b>
<%= ( ) %>
</B></TD>
<% next %>
</tr><% ( )
loop%>
</table>
<%
rstemp.close
set rstemp=nothing
cn.close
set cn=nothing
end sub%>
</body>
</html> 展开
<%@ Language=“VBScript” %>
<html>
<body>
<form Method=“post” action=““>
学号<input type=“text” size=6 name=“xh”>
姓名<input type=“text” size=6 name=“xm”>
成绩<input type=“text”“ size=6 name=“cj”>
<input type=“submit” value=“提交”>
<input type=“reset” value=“重置”>
</FORM>
<% if request.form(“xh”)<>““ then
Set cn = Server.CreateObject(“ADODB.Connection”)
Conn= ( )
cn.Open conn
sql=“insert into cj(学号,姓名,成绩) Values(‘“&request.form(“xh”)&”’,’”& request.form(“xm”)&”’,” request.form(“cj”)&”)”
( )sql=“select * form cj”
call q(sql) %>
<% sub q(sql) ‘显示记录的过程
set rstemp= ( )
howmanyfields=rstemp.fields.count-1%>
<table border=1><tr>
<%for i=0 to howmanyfields%>
<td><b>
<%= ( )%>
</B></TD>
<% next %>
</tr>
<%Do while ( ) %>
<%for i=0 to howmanyfields%>
<td><b>
<%= ( ) %>
</B></TD>
<% next %>
</tr><% ( )
loop%>
</table>
<%
rstemp.close
set rstemp=nothing
cn.close
set cn=nothing
end sub%>
</body>
</html> 展开
1个回答
展开全部
老师给的作业?自己应该努力学习下。
给的单引号和双引号都不是英文状态下的最后上了end if没给。完整如下,自己对应括号内容
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>学生成绩录入及查询</title>
</head>
<body>
<form Method="post" action="">
学号<input type="text" size=6 name="xh">
姓名<input type="text" size=6 name="xm">
成绩<input type="text"" size=6 name="cj">
<input type="submit" value="提交">
<input type="reset" value="重置">
</FORM>
<%
if request.form("xh")<>"" then
Set cn = Server.CreateObject("ADODB.Connection")
Conn= "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("KS.mdb")
cn.Open conn
sql = "insert into cj (学号,姓名,成绩) values ('" & request.form("xh") & "','" & request.form("xm") & "'," & request.form("cj") & ")"
cn.execute(sql)
sql="select * from cj"
call q(sql)
%>
<%
sub q(sql) '显示记录的过程
set rstemp= cn.execute(sql)
howmanyfields = rstemp.fields.count-1
%>
<table border=1>
<tr>
<%
for i=0 to howmanyfields
%>
<td>
<b>
<%= rstemp.fields(i).name %>
</b>
</td>
<%
next
%>
</tr>
<%
Do while not rstemp.eof
%>
<%
for i=0 to howmanyfields
%>
<td>
<b>
<%= rstemp.fields(i).value %>
</b>
</td>
<%
next
%>
</tr>
<%
rstemp.movenext
loop
%>
</table>
<%
rstemp.close
set rstemp=nothing
cn.close
set cn=nothing
end sub
end if
%>
</body>
</html>
给的单引号和双引号都不是英文状态下的最后上了end if没给。完整如下,自己对应括号内容
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>学生成绩录入及查询</title>
</head>
<body>
<form Method="post" action="">
学号<input type="text" size=6 name="xh">
姓名<input type="text" size=6 name="xm">
成绩<input type="text"" size=6 name="cj">
<input type="submit" value="提交">
<input type="reset" value="重置">
</FORM>
<%
if request.form("xh")<>"" then
Set cn = Server.CreateObject("ADODB.Connection")
Conn= "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("KS.mdb")
cn.Open conn
sql = "insert into cj (学号,姓名,成绩) values ('" & request.form("xh") & "','" & request.form("xm") & "'," & request.form("cj") & ")"
cn.execute(sql)
sql="select * from cj"
call q(sql)
%>
<%
sub q(sql) '显示记录的过程
set rstemp= cn.execute(sql)
howmanyfields = rstemp.fields.count-1
%>
<table border=1>
<tr>
<%
for i=0 to howmanyfields
%>
<td>
<b>
<%= rstemp.fields(i).name %>
</b>
</td>
<%
next
%>
</tr>
<%
Do while not rstemp.eof
%>
<%
for i=0 to howmanyfields
%>
<td>
<b>
<%= rstemp.fields(i).value %>
</b>
</td>
<%
next
%>
</tr>
<%
rstemp.movenext
loop
%>
</table>
<%
rstemp.close
set rstemp=nothing
cn.close
set cn=nothing
end sub
end if
%>
</body>
</html>
更多追问追答
追问
你怎么知道是老师给的啊 。。哈哈、、、、、、、
追答
放心我不认识你的老师,哈哈
看这内容就像。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询