string uptcmd="update login_db set name_ID=@name1,psw_ID=@psw1 where dept_ID=@dept_ID";
OleDbConnection myconnection=new OleDbConnection(CnnString);
OleDbCommand mycommand=new OleDbCommand(uptcmd,myconnection);
mycommand.Parameters.Add(new OleDbParameter("@dept_ID",OleDbType.VarChar,50));
mycommand.Parameters["@dept_ID"].Value=DataGrid1.DataKeys[(int)E.Item.ItemIndex];
mycommand.Parameters.Add(new OleDbParameter("@name1",OleDbType.VarChar,50));
mycommand.Parameters["@name1"].Value=((TextBox)(E.Item.Cells[3].Controls[0])).Text;
mycommand.Parameters.Add(new OleDbParameter("@psw1",OleDbType.VarChar,50));
mycommand.Parameters["@psw1"].Value=((TextBox)(E.Item.Cells[4].Controls[0])).Text;
mycommand.Connection.Open();
mycommand.ExecuteNonQuery();
mycommand.Connection.Close();
还有就是E.Item.Cells[4].Controls[0],这里,这个Cells[]和Controls[]分别是做什么的,由什么决定?
OleDbConnection myconnection=new OleDbConnection(CnnString);
OleDbCommand mycommand=new OleDbCommand(uptcmd,myconnection);
mycommand.Parameters.Add(new OleDbParameter("@dept_ID",OleDbType.VarChar,50));
mycommand.Parameters["@dept_ID"].Value=DataGrid1.DataKeys[(int)E.Item.ItemIndex];
mycommand.Parameters.Add(new OleDbParameter("@name1",OleDbType.VarChar,50));
mycommand.Parameters["@name1"].Value=((TextBox)(E.Item.Cells[3].Controls[0])).Text;
mycommand.Parameters.Add(new OleDbParameter("@psw1",OleDbType.VarChar,50));
mycommand.Parameters["@psw1"].Value=((TextBox)(E.Item.Cells[4].Controls[0])).Text;
mycommand.Connection.Open();
mycommand.ExecuteNonQuery();
mycommand.Connection.Close();
还有就是E.Item.Cells[4].Controls[0],这里,这个Cells[]和Controls[]分别是做什么的,由什么决定?
解决方案 »
- DatePicker里怎样设定日期的选择范围?
- C#中怎样让鼠标的滚轮禁用(winform中)
- #region能多行註釋嗎?
- c#,进程
- Activator.CreateInstance(type) 的问题。高手进
- [求助]关于动态数组ArrayList的问题
- C#中如何处理等待任一线程的结束?比如C++中的WSAWaitForMultipleEvents函数
- 巨难!!以前问过没有解决.C#使用COM对象时,调用COM的函数,其默认参数怎样传递??
- 如何将一个项目的全局把握好
- 在datagrid中如何格式化数字字段
- [求助]我想执行一个带插入功能的存储过程,但是总是插入不进去,请指教.
- 100分求一正则表达式
{
mycommand.Connection.Open();
mycommand.ExecuteNonQuery();
mycommand.Connection.Close();
} catch(OleDBException)
{
.... }E.Item.Cells[4].Controls[0],
当前行的第5列(是个模版列)中第一个控件(不过我印象中control的index似乎从1开始)