要实现的效果,通过页面修改删除sql server数据库中的数据! 以下是所有的代码,问题是如何修改更新?? login.asp <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>无标题文档</title> <style type="text/css"> <!-- body { background-color: #DEE3ED; } input{font-size:9pt; border:1px solid #888888; background-color:#eeeeee;} table{ font-size:9pt; word-break:break-all; } --> </style> </head>
<body> <%bt=request.Form("bt") if bt<>"" then session("server")=request.Form("server") session("uid")=request.Form("uid") session("pwd")=request.Form("pwd") database=request.Form("database") if database="" then session("database")="master" else session("database")=database end if response.Redirect "index.asp" end if %> <form name="form1" method="post" action=""> <table width="394" height="100" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#000066"> <tr bgcolor="#B0BDD3"> <td width="136"><div align="center">地址</div></td> <td width="464"><input name="server" type="text" id="server" size="40"></td> </tr> <tr bgcolor="#B0BDD3"> <td><div align="center">帐号</div></td> <td><input name="uid" type="text" id="uid" size="40"></td> </tr> <tr bgcolor="#B0BDD3"> <td><div align="center">密码</div></td> <td><input name="pwd" type="text" id="pwd" size="40"></td> </tr> <tr bgcolor="#B0BDD3"> <td><div align="center">数据库</div></td> <td><input name="database" type="text" id="database" size="40"></td> </tr> <tr bgcolor="#B0BDD3"> <td> </td> <td height="20"><input name="bt" type="submit" id="bt" value="提交"> <input type="reset" name="Submit2" value="重置"></td> </tr> </table> </form> </body> </html> conn.asp <% 'response.Write session("server")&session("uid") response.Buffer=true if session("server")="" or session("uid")="" then response.Redirect "login.asp" else set conn=server.CreateObject("adodb.connection") if session("pwd")<>"" then constr="driver={sql server};server="&session("server")&";uid="&session("uid")&";pwd="&session("pwd")&";database="&session("database")&";" 'response.Write constr else constr="driver={sql server};server="&session("server")&";uid="&session("uid")&";database="&session("database")&";" 'response.Write constr end if conn.open constr 'response.Redirect "index.asp" 'response.Write "<script>window.location='index.asp';</script>" 'end if end if%> <style type="text/css"> <!-- body { background-color: #DEE3ED; } input{font-size:9pt; border:1px solid #888888; background-color:#eeeeee;} table{ font-size:9pt; word-break:break-all; } --> </style> left.asp <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> <!--#include file="conn.asp"--><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>无标题文档</title> </head>
<body> <% set rs=server.CreateObject("adodb.recordset") Set rs=conn.OpenSchema(20) %> <table width="96%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#000066"> <tr> <td height="20" bgcolor="#DEE3ED"><strong>选择数据表</strong></td> </tr> <% do while not rs.eof if rs("TABLE_TYPE")="TABLE" then%> <tr> <td bgcolor="#DEE3ED"><a href="main.asp?table=<%= rs("TABLE_NAME") %>" target="mainframe"><%= rs("TABLE_NAME") %></a> </td> </tr> <% end if rs.movenext loop %> <tr> <td height="20" bgcolor="#DEE3ED"><a href="out.asp" target="mainframe">退出系统</a></td> </tr> </table> <!--table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000066"> <tr> <td height="20" bgcolor="#DEE3ED">表名</td> </tr> <% 'do while not rs.eof 'and rs("TABLE_TYPE")="TABLE" %> <tr> <td height="20" bgcolor="#DEE3ED"> <% 'If rs("TABLE_TYPE")="TABLE" and left(rs("TABLE_NAME"),4)<>"MSys" Then 'response.Write rs("TABLE_TYPE")&rs("TABLE_NAME") 'end if %></td> </tr> <% 'rs.movenext 'loop 'rs.close %> </table> </body> </html--> main.asp <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> <!--#include file="conn.asp"--> <% table=request.QueryString("table") set rs=server.CreateObject("adodb.recordset") sql="select * from "&table&"" rs.open sql,conn,3,2 %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>信息记录</title> </head>
<body> <table width="100%" height="20" border="0" cellpadding="0" cellspacing="1" bgcolor="#000066"> <tr> <td bgcolor="#DEE3ED">当前的操作表<%= table %> </td> </tr> </table> <br> <form name="form1" > <table width="100%" height="40" border="0" cellpadding="0" cellspacing="1" bgcolor="#000066"> <tr> <% for i=0 to rs.fields.count-1 %> <td bgcolor="#DEE3ED"><%= rs.fields(i).name %> </td> <% next %> <td bgcolor="#DEE3ED">操作</td> </tr> <% do while not rs.eof %> <tr> <% for i=0 to rs.fields.count-1 %> <td bgcolor="#DEE3ED"><% If rs.fields(i).type="201" and len(rs.fields(i).value)>50 Then %> <textarea name="textarea" cols="50" rows="6" style="border:1px solid #888888;overflow:auto;"><%= rs.fields(i).value%></textarea> <% Else %> <%= rs.fields(i).value%><% End If %></td> <% next %> <td bgcolor="#DEE3ED"><a href="edit.asp?action=edit&table=<%=table%>&<%=rs.fields(0).name%>=<%=rs(0)%>">修改</a>|<a href="edit.asp?action=del&table=<%=table%>&id=<%=rs(0)%>">删除</a></td> </tr> <% rs.movenext loop %> </table> </form> </body> </html> edit.asp <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> <!--#include file="conn.asp"--> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>修改</title> <% for each x in request.QueryString if x<>"action" and x<>"table" then set rs=server.CreateObject("adodb.recordset") sql="select * from "&request.QueryString("table")&" where "&x&"='"&request.QueryString(x)&"'" rs.open sql,conn,3,2
%>
<% bt=request.form("bt") if bt<>"" then y=0 for each c in request.Form if c<>"提交" then response.Write c&"="&request.Form(c)&"<br>" end if next end if %> <form name="form1" method="post" action=""> <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000077"> <% for each b in rs.fields %> <tr bgcolor="#DEE3EF"> <td width="19%" height="20"><div align="center"><%= b.name %> </div></td> <td width="81%"><input name="<%=b.name%>" type="text" id="<%=b.name%>" value="<%=b.value%>" size="60"></td> </tr> <% next %> <tr bgcolor="#DEE3EF"> <td height="20"> </td> <td><input name="bt" type="submit" id="bt" value="提交"> <input type="reset" name="Submit2" value="重置"></td> </tr> </table> </form> <%
end if next 'case "edit" %> 问题就出在edit.asp中, 我不知道那个sql应该怎么写!