请前辈们帮我看一下我写的简单程序为什么只能执行查询,不能更新
<%@ Page language= "C# " Debug=True %>
<%@ Import Namespace= "System.Data " %>
<%@ Import Namespace= "System.Data.OleDb " %>
<Script Language= "C# " Runat= "Server ">
OleDbConnection MyConn;
public void Page_Load(Object src,EventArgs e)
{
//数据连接字符串
string MyConnString= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= "+Server.MapPath( ". ")+ "..\\RENSHI.MDB; ";
MyConn=new OleDbConnection(MyConnString);
MyConn.Open();
if(!Page.IsPostBack)
{
//将数据绑定至Orign数据表格
BindGrid(Orign);
}
}
public void btnUpdate_Click(Object sender,EventArgs e)
{
//更新语句
string strUpdate = "UPDATE department SET department.part_pho= 'jjjj ' ";
OleDbCommand MyComm = new OleDbCommand(strUpdate, MyConn);
//执行更新语句
MyComm.ExecuteNonQuery();
//MyComm.ExecuteReader();
//数据绑定至New数据表格
//BindGrid(New);
}
public void BindGrid(DataGrid dg)
{
OleDbDataReader dr;
string strSel= "Select * from department ";
OleDbCommand MyComm=new OleDbCommand(strSel,MyConn);
//注意下面
dr=MyComm.ExecuteReader();
dg.DataSource=dr;
dg.DataBind();
}
</Script>
<HTML>
<HEAD>
<TITLE> MyUpData </TITLE>
</HEAD>
<BODY>
<form id = "form1 " runat= "server ">
<CENTER>
<TABLE>
<TR>
<TD> 原始数据 </TD>
<TD> 更新后数据 </TD>
</TR>
<TR>
<TD> <asp:DataGrid id= "Orign " runat= "server " AutoGenerateColumns= "False ">
<Columns>
<asp:BoundColumn HeaderText= "ID " DataField= "part_id "/>
<asp:BoundColumn HeaderText= "电话 " DataField= "part_pho "/>
<asp:BoundColumn HeaderText= "负责人 " DataField= "principal "/>
</Columns>
</asp:DataGrid>
</TD>
<TD> <asp:DataGrid id= "New " runat= "server " AutoGenerateColumns= "False ">
<Columns>
<asp:BoundColumn HeaderText= "ID " DataField= "part_id "/>
<asp:BoundColumn HeaderText= "电话 " DataField= "part_pho "/>
<asp:BoundColumn HeaderText= "负责人 " DataField= "principal "/>
</Columns>
</asp:DataGrid>
</TD>
</TR>
<TR>
<TD>
<asp:Button id= "btnUpdate " text= "更新 " OnClick= "btnUpdate_Click " runat= "server "/>
</TD>