<% 'adodb connection' dim conn,conntol conntol = "driver={SQL Server};server=127.0.0.1;uid=sa;pwd=test11;database=test" set conn = server.CreateObject("adodb.connection") conn.open conntol %>
<%@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>A SIMPLE ASP</title> <!--#include file="conn.asp"--> </head> <body> <% if request("act") = "add" then %> <form action="" method="post"> <table> <tr> <td>Col1</td><td><input type="text" name="col1" /></td> </tr> <tr> <td>Col2</td><td><input type="text" name="col2" /></td> </tr> <tr> <td>Col3</td><td><input type="text" name="col3" /></td> </tr> <tr> <td colspan="2"><input type="button" name="save" value="保存" onclick="this.form.action='save.asp';this.form.submit();" /> <input type="button" name="cancel" value="取消" onclick="location.href='index.asp';" /> </td> </tr> </table> </form> <% end if %> <form action="" method="post"> <table> <tr> <td>Col1</td><td><input type="text" name="col1" /></td> <td><input type="submit" name="search" value="查询" onclick="location.href=index.asp" /></td> <td><input type="button" name="add" value="添加" onclick="this.form.action='index.asp?act=add';this.form.submit();" /></td> </tr> </table> </form> <form action="" method="post"> <% dim col1 page = clng(request("page")) if request("col1") = "" then col1 = "%" set rs = server.CreateObject("adodb.recordset") rs.open "select * from t1",conn,1,3 else col1 = request("col1") set rs = server.CreateObject("adodb.recordset") rs.open "select * from t1 where col1 like '%"&request("col1")&"%' ",conn,1,3 end if %> <table border="1"> <tr style="background-color:yellow;"> <td><input type="checkbox" /></td> <td>Col1</td> <td>Col2</td> <td>Col3</td> </tr> <% if rs.eof or rs.bof then %> <tr> <td colspan="4">no data</td> </tr> <% else rs.pagesize=2 if page=0 then page=1 pages=rs.pagecount if page > pages then page=pages rs.absolutepage=page for i=1 to rs.pagesize %> <tr> <td><input type="checkbox" name="checkbox" value="<%= rs("col1") %>" /></td> <td><%= rs("col1") %></td> <td><%= rs("col2") %></td> <td><%= rs("col3") %></td> </tr> <% rs.movenext if rs.eof then exit for next end if %> </table> <table> <tr> <td> <% response.write "<a href=index.asp?page=1&col1="& col1 &">首页</a> " response.write "<a href=index.asp?page="&page-1&"&col1="& col1 &">上一页</a> " response.write "<a href=index.asp?page="&(page+1)& "&col1="& col1 &">下一页</a>" response.write "<a href=index.asp?page="&rs.pagecount&"&col1="& col1 &">尾页</a>" rs.close set rs = nothing %> </td> </tr> </table> <table> <tr> <td><input type="button" name="del" value="删除" onclick="if(confirm('确定要删除吗?')){this.form.action='delete.asp';this.form.submit();}"/> <input type="button" name="modify" value="修改" onclick="this.form.action='modify.asp';this.form.submit();" /></td> </tr> </table> </form> <body> </body> </html>
<!--#include file="conn.asp"--> <% set rs = server.CreateObject("adodb.recordset") rs.open "select * from t1 where col1 = '"&request("col1")&"'",conn,1,3 if rs.eof or rs.bof then rs.addnew rs("col1") = request("col1") rs("col2") = request("col2") rs("col3") = request("col3") rs.update rs.close set rs = nothing response.Write("<script language='javascript'>alert('添加成功!');</script>") response.Write("<script language='javascript'>location.href='index.asp';</script>") else response.Write("<script language='javascript'>alert('数据已经存在!');</script>") response.Write("<script language='javascript'>history.back();</script>") 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> <!--#include file="conn.asp"--> </head> <body> <form action="" method="post"> <table border="1"> <tr> <td>Col1</td> <td>Col2</td> <td>Col3</td> </tr> <% dim cb cb = request("checkbox") cbs = split(cb,",") if cb = "" then response.Write("<script language='javascript'>alert('没有修改的内容!');</script>") response.Write("<script language='javascript'>history.back();</script>") end if for i=lbound(cbs) to ubound(cbs) set rs = server.CreateObject("adodb.recordset") rs.open "select * from t1 where col1 = '"&cbs(i)&"'",conn,1,3 %> <tr> <td><input type="text" name="col1" value="<%= rs("col1") %>" /></td> <td><input type="text" name="col2" value="<%= rs("col2") %>" /></td> <td><input type="text" name="col3" value="<%= rs("col3") %>" /></td> </tr> <% set rs = nothing next %> </table> <table> <tr> <td><input type="button" name="save" value="保存" onclick="this.form.action='save1.asp';this.form.submit();" /> </td> </tr> </table> </form> </body> </html>
<!--#include file="conn.asp"--> <% dim col1,col2,col3 col1 = request("col1") col2 = request("col2") col3 = request("col3") col1s = split(col1,",") col2s = split(col2,",") col3s = split(col3,",") if trim(col1)="" then Response.Write("<script language=javascript>alert('没有要修改的数据!');</script>") Response.Write("<script language=javascript>history.back();</script>") end if for i=lbound(col1s) to ubound(col1s) set rs = server.CreateObject("adodb.recordset") rs.open "select * from t1 where col1 = '"&trim(col1s(i))&"'",conn,1,3 rs("col2") = col2s(i) rs("col3") = col3s(i) rs.update rs.close set rs = nothing next response.Write("<script language='javascript'>alert('修改成功!');</script>") response.Write("<script language='javascript'>location.href='index.asp';</script>") %>
<!--#include file="conn.asp"--> <% dim cb cb = request("checkbox") cbs = split(cb,",") if trim(cb)="" then Response.Write("<script language=javascript>alert('没有要删除的数据!');</script>") Response.Write("<script language=javascript>history.back();</script>") end if for i=lbound(cbs) to ubound(cbs) Set rs= server.CreateObject("adodb.recordset") rs.Open "delete from t1 where col1 = '"&trim(cbs(i))&"'",conn,1,3 set rs=nothing next Response.Write("<script language=javascript>alert('删除成功!');</script>") Response.Write("<script language=javascript>location.href='index.asp';</script>") %>