[讨论]修改不了数据
<script runat="server">private void Page_Load(Object sender , EventArgs E)
{
OleDbConnection cnn;
OleDbCommand cmd;
OleDbDataReader datar;
DataSet dt=new DataSet();
string strcnn,sql;
string theID;
int Ss;
theID=Request.QueryString["id"].Trim();
Ss=Convert.ToInt32(theID);
strcnn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("../../EDNdata/EDNdata.mdb");
cnn=new OleDbConnection(strcnn);
cnn.Open();
sql="select * from keyword where id="+ Ss;
cmd=new OleDbCommand(sql,cnn);
datar=cmd.ExecuteReader();
if(datar.Read())
{
AID.Text=datar["id"].ToString();
key.Text=datar["Title"].ToString();
url.Text=datar["url"].ToString();
}
cnn.Close();
}
//---------------------------------------------------------------------------
public void save_click(Object sender , EventArgs E)
{
OleDbConnection cnn;
OleDbCommand cmd;
string strcnn,sql;
string thekey,theurl;
thekey=key.Text;
theurl=url.Text;
strcnn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("../../EDNdata/EDNdata.mdb");
cnn=new OleDbConnection(strcnn);
cnn.Open();
sql="update keyword set Title='"+ thekey + "',url='" + theurl + "' where id=" + AID.Text.Trim();
cmd=new OleDbCommand(sql,cnn);
cmd.ExecuteNonQuery();
cnn.Close();
this.Page.RegisterStartupScript("", "<script>alert('添加成功')<script>");
}
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<form runat="server">
<table width="760" height="150" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="200"> </td>
<td width="560"> </td>
</tr>
<tr>
<td align="right"> </td>
<td>
<asp:TextBox ID="AID" runat="server" Visible="false"></asp:TextBox>
<asp:TextBox ID="key" runat="server" Width="300"></asp:TextBox>
</td>
</tr>
<tr>
<td> </td>
<td>
<asp:Textbox ID="url" runat="server" Width="500"></asp:Textbox>
</td>
</tr>
<tr>
<td> </td>
<td>
<asp:Button runat="server" ID="button1" Text="修改" OnClick="save_click"></asp:Button>
</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
</form>
</body>
</html>
大帮我看一下...为什么读出数据却修改不了..程序没有提示错误
[此贴子已经被作者于2007-8-22 16:33:01编辑过]