asp增删改查代码
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
<!--#include file="conn.asp"-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
delete_file(re("id"))
end if
rs.Close
set rs=nothing
sql="delete from students where id="&id(i)
rs.execute sql,shu1
next
</td>
</tr>
<tr>
<td align="center">age</td>
<td align="center"><input type="text" name="age" value="<%=rs("age")%>" id="age"/></td>
</tr>
<tr>
<td align="center"><label>
<input type="submit" name="Submit" value="修改" onClick=" return sub0()" />
sql="select * from students"
Set rs=Server.CreateObject("ADODB.Recordset")
rs.Open sql,conn,2,2
rs.AddNew
rs("name")=comname
sql="select from students where id="&id(i)
Set rs=Server.CreateObject("ADODB.Recordset")
rs.execute(sql)
if not rs.EOF then
<!--#include file="conn.asp"-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>pldelete</title>
</head>
<body>
<%
id=request.Form("sid")
id=Sqlit(id,",")
shu=0
for i=1 to UBound(id)
</tr>
<tr>
<td align="center">sex</td>
<td align="center"><input type="text" name="sex" value="<%=rs("sex")%>" id="sex"/></td>
rs("sex")=comsex
rs("age")=comage
rs.Update
rs.close
set rs=nothing
Response.Write "<script language='javascript'>alert('成功添加');"
if shu>0 then
response.Write ("记录已经删除了!")
else
response.Write("数据仍然存在");
end if
%>
</body>
</html>
-----------------------------------------------------------单条查询---------------------------------------------------------------------------------------------
<!--#include file="conn.asp"-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
sql="select * from students where id ="&id
Set rs=Server.CreateObject("ADODB.Recordset")
Set rs=conn.Execute(sql)
%>
<body>
<tr>
<td align="center">name</td>
<td align="center">
<input type="text" name="name" value="<%=rs("name")%>" id="name"/>
<form action="update_DB.asp?uid=<%=rs("id")%>" method="post">
<table width="80%" border="0" align="center">
response.Write "javascript:window.document.location='testselectDB.asp';</script>"
%>
</body>
</html>
------------------------------------------------------------删除---------------------------------------------------------------------------------------------
</label></td>
<td align="center"><input type="reset" name="Submit2" value="重置" />
return false;
}
var sex=document.getElementById("sex").value;
if (sex==0)
{
alert("请输入性别");
r
eturn false;
if(name==0)
{
alert("清输入姓名");
return false;
}
var age=document.getElementById("age").value;
if(age==0)
{
alert("请输入年龄");
}
}
//-->
</script>
</head>
<%
id=request("uid")
''set dbconnection=Server.CREATEOBJECT("ADODB.CONNECTION")
<title>operateDB</title>
</head>
<body>
<% comname=request.Form("name")
comsex=request.Form("sex")
comage=request.Form("age")
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
------------------------------------------------------------增加---------------------------------------------------------------------------------------------
<title>operateDB</title>
<script e="javascript">
<!--
function sub0()
{
var name=document.getElementById("name").value;
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
set dbconnection=Server.CREATEOBJECT("ADODB.CONNECTION")
'DBPath=Server.MapPath(Students.mdb)
'dbconnection.Open"driver={Microsoft Access Dirver(*.mdb)};dbp"& DBPath
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
delete_file(re("id"))
end if
rs.Close
set rs=nothing
sql="delete from students where id="&id(i)
rs.execute sql,shu1
next
</td>
</tr>
<tr>
<td align="center">age</td>
<td align="center"><input type="text" name="age" value="<%=rs("age")%>" id="age"/></td>
</tr>
<tr>
<td align="center"><label>
<input type="submit" name="Submit" value="修改" onClick=" return sub0()" />
sql="select * from students"
Set rs=Server.CreateObject("ADODB.Recordset")
rs.Open sql,conn,2,2
rs.AddNew
rs("name")=comname
sql="select from students where id="&id(i)
Set rs=Server.CreateObject("ADODB.Recordset")
rs.execute(sql)
if not rs.EOF then
<!--#include file="conn.asp"-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>pldelete</title>
</head>
<body>
<%
id=request.Form("sid")
id=Sqlit(id,",")
shu=0
for i=1 to UBound(id)
</tr>
<tr>
<td align="center">sex</td>
<td align="center"><input type="text" name="sex" value="<%=rs("sex")%>" id="sex"/></td>
rs("sex")=comsex
rs("age")=comage
rs.Update
rs.close
set rs=nothing
Response.Write "<script language='javascript'>alert('成功添加');"
if shu>0 then
response.Write ("记录已经删除了!")
else
response.Write("数据仍然存在");
end if
%>
</body>
</html>
-----------------------------------------------------------单条查询---------------------------------------------------------------------------------------------
<!--#include file="conn.asp"-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
sql="select * from students where id ="&id
Set rs=Server.CreateObject("ADODB.Recordset")
Set rs=conn.Execute(sql)
%>
<body>
<tr>
<td align="center">name</td>
<td align="center">
<input type="text" name="name" value="<%=rs("name")%>" id="name"/>
<form action="update_DB.asp?uid=<%=rs("id")%>" method="post">
<table width="80%" border="0" align="center">
response.Write "javascript:window.document.location='testselectDB.asp';</script>"
%>
</body>
</html>
------------------------------------------------------------删除---------------------------------------------------------------------------------------------
</label></td>
<td align="center"><input type="reset" name="Submit2" value="重置" />
return false;
}
var sex=document.getElementById("sex").value;
if (sex==0)
{
alert("请输入性别");
r
eturn false;
if(name==0)
{
alert("清输入姓名");
return false;
}
var age=document.getElementById("age").value;
if(age==0)
{
alert("请输入年龄");
}
}
//-->
</script>
</head>
<%
id=request("uid")
''set dbconnection=Server.CREATEOBJECT("ADODB.CONNECTION")
<title>operateDB</title>
</head>
<body>
<% comname=request.Form("name")
comsex=request.Form("sex")
comage=request.Form("age")
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
------------------------------------------------------------增加---------------------------------------------------------------------------------------------
<title>operateDB</title>
<script e="javascript">
<!--
function sub0()
{
var name=document.getElementById("name").value;
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
set dbconnection=Server.CREATEOBJECT("ADODB.CONNECTION")
'DBPath=Server.MapPath(Students.mdb)
'dbconnection.Open"driver={Microsoft Access Dirver(*.mdb)};dbp"& DBPath