作者seavoice (NNN)
看板C_Sharp
标题请教一下在Datagridview做资料更新的问题
时间Thu Jan 4 16:06:24 2007
各位先进好
小弟目前再设计一个表单就是上面有textbox可供使用者输入
底下有Datagridview会立即显示上面所新增的资料
而新增资料的旁边有编辑按钮
按完之後会变成可供使用者更新资料的画面
目前就是卡在我改完资料按更新按钮没有动作
这是在rowupdating里的程式码
protected void gvwcase_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
if (!checkField_Case(gvwcase.Rows[e.RowIndex]))
e.Cancel = true;
SqlConnection connection2=new SqlConnection("Data Source=BRIAN923;
Initial Catalog=EIPDB;User ID=eipms;Password=eipms2940");
SqlCommand command2 = new SqlCommand("UPDATE dbo.Refresh
SET refresh_content=@refresh_content, refresh_date =@refresh_date
WHERE (refresh_partment_id = @refresh_partment_id)", connection2);
command2.Parameters.Add("@refresh_content", SqlDbType.VarChar, 50).Value
= refresh_content.Text;
command2.Parameters.Add("@refresh_date", SqlDbType.Char, 10).Value
= refresh_date.Text;
connection2.Open();
command2.ExecuteNonQuery();
connection2.Close();
}
请教一下这样为何还是无法更新呢?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 203.67.241.62
1F:推 tomex:写在RowUpdated()事件,而非ing()中 01/05 02:27