为什么这段代码不能修改最后一个字段啊!
<% @ Page Language="C#" %>
<% @ Import Namespace="System.Data" %>
<% @ Import Namespace="System.Data.OleDb" %>
<Script Language="C#" Runat="Server">
OleDbDataReader dr;
public void Page_Load(Object src,EventArgs e)
{
string MyConnString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("."
+"..\\DataBase\\db1.mdb;";
OleDbConnection MyConn=new OleDbConnection(MyConnString);
string strSel="Select * from BookMark";
OleDbCommand MyComm=new OleDbCommand(strSel,MyConn);
MyComm.Connection.Open();
dr=MyComm.ExecuteReader();
}
public void Button1(Object sender,EventArgs e)
{ string returnid=Request.QueryString["id"];
string MyConnString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("."
+"..\\DataBase\\db1.mdb;";
OleDbConnection MyConn = new OleDbConnection(MyConnString);
string strUpdate = "Update [BookMark] Set SiteName = '" + website.Text + "',URL = '" + introduce.Text + "' Where ID = " + returnid;
OleDbCommand MyComm=new OleDbCommand(strUpdate,MyConn);
MyComm.Connection.Open();
dr=MyComm.ExecuteReader();
MyConn.Close();
Response.Redirect("user_member.aspx"
;
}
</script>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<form runat="server">
<table width=500 border=1 cellspacing=0 cellpadding=0 align=center bordercolorlight=#ffffff bordercolordark=#cccccc>
<tr bgcolor=#aaaadd><td>网站名</td><td>网址</td><td>介绍</td><td>删除</td><td>修改</td></tr>
<%
while (dr.Read())
{
%>
<tr>
<td><%=dr["SiteName"].ToString()%></td><td><%=dr["URL"].ToString()%></td><td><%=dr["Comment"].ToString()%></td>
<td><a href=del.aspx?id=<%=dr["id"].ToString()%>>删除</a></td>
<td>
<a href=mod.aspx?id=<%=dr["id"].ToString()%>>修改</a>
</td>
</tr>
<%}
dr.Close();
%>
</table>
<%
string returnid=Request.QueryString["id"];
string MyConnString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("."
+"..\\DataBase\\db1.mdb;";
OleDbConnection MyConn=new OleDbConnection(MyConnString);
string strSel="Select * from BookMark Where ID="+returnid;
OleDbCommand MyComm=new OleDbCommand(strSel,MyConn);
MyComm.Connection.Open();
dr=MyComm.ExecuteReader();
if(dr.Read())
{
website.Text =dr["SiteName"].ToString();
linkurl.Text=dr["URL"].ToString();
introduce.Text=dr["Comment"].ToString();
}
%>
<table width=500 border=1 cellspacing=0 cellpadding=0 align=center bordercolorlight=#ffffff bordercolordark=#cccccc>
<tr>
<td>网站名:</td>
<td><asp:TextBox id="website" runat="server" /></td>
<td align="center"> </td>
</tr>
<tr>
<td>网 址:</td>
<td><asp:TextBox id="linkurl" runat="server" /></td>
<td align="center"><asp:Button Text="修改" onClick="Button1" Runat="Server" /></td>
</tr>
<tr>
<td>介 绍:</td>
<td><asp:TextBox id="introduce" runat="server" /></td>
<td align="center"><input type="reset" value="重置"></td>
</tr>
</table>
</form>
</body>
</html>