为什么我DataGrid更新记录时没有反应啊???
仙人掌 2003-08-22 01:03:22 string updateCmd = "UPDATE daywork SET starttime = @starttime, endtime = @endtime, about = @about, riji = @riji, "
+ "beizhu = @beizhu where id = @id";
string strConn =ConfigurationSettings.AppSettings["strConn"];
SqlConnection Conn=new SqlConnection(strConn);
SqlCommand myCommand = new SqlCommand(updateCmd,Conn);
myCommand.Parameters.Add(new SqlParameter("@id", SqlDbType.Int, 4));
myCommand.Parameters["@id"].Value=dGridList.DataKeys[(int)e.Item.ItemIndex];
myCommand.Parameters.Add(new SqlParameter("@starttime", SqlDbType.NVarChar, 50));
myCommand.Parameters["@starttime"].Value=((TextBox)e.Item.Cells[1].Controls[0]).Text;
myCommand.Parameters.Add(new SqlParameter("@endtime", SqlDbType.NVarChar, 50));
myCommand.Parameters["@endtime"].Value=((TextBox)e.Item.Cells[2].Controls[0]).Text;
myCommand.Parameters.Add(new SqlParameter("@about", SqlDbType.NVarChar, 50));
myCommand.Parameters["@about"].Value=((TextBox)e.Item.Cells[4].Controls[0]).Text;
myCommand.Parameters.Add(new SqlParameter("@riji", SqlDbType.NText, 16));
myCommand.Parameters["@riji"].Value=((TextBox)e.Item.Cells[3].Controls[0]).Text;
myCommand.Parameters.Add(new SqlParameter("@beizhu", SqlDbType.NText, 16));
myCommand.Parameters["@beizhu"].Value=((TextBox)e.Item.Cells[5].Controls[0]).Text;
myCommand.Connection.Open();
Response.Write(myCommand.Parameters["@riji"].Value);
try
{
myCommand.ExecuteNonQuery();
//Message.InnerHtml = "<b>已更新记录</b><br>" + updateCmd;
dGridList.EditItemIndex = -1;
Response.Write(updateCmd);
}
catch (Exception exec)
{
Response.Write(exec.ToString());
}
myCommand.Connection.Close();
BindData();
有什么地方不对吗?