以下是程序!!
void DataGrid_Update(object sender,DataGridCommandEventArgs E)
{
string Provider,Database,Connstr;
Provider="Microsoft.Jet.OLEDB.4.0;";
Database=Server.MapPath("wow.mdb");
Connstr="Provider="+Provider+"Data Source="+Database;
OleDbConnection Connn=new OleDbConnection(Connstr);
Connn.Open();
string strSQL="update edit set editpwd=@d where editname=@e";
OleDbCommand Commm=new OleDbCommand(strSQL,Connn);
Commm.Parameters.Add(new OleDbParameter("@d",OleDbType.Char));
string colvalue=((TextBox)E.Item.Cells[3].Controls[0]).Text;
Commm.Parameters["@d"].Value=colvalue;
Commm.Parameters.Add(new OleDbParameter("@e",OleDbType.Char));
Commm.Parameters["@e"].Value=DataGrid1.DataKeys[(int)E.Item.ItemIndex];
try
{
Commm.ExecuteNonQuery();
DataGrid1.EditItemIndex=-1;
}
finally
{
Connn.Close();
BindGrid();
}
}
[此贴子已经被作者于2007-3-29 2:31:25编辑过]