private void button2_Click(object sender, EventArgs e)//修改信息
{
DataSet ds = new DataSet();
OleDbConnection conn = new OleDbConnection("Data Source=F:\\c#.net\\学生信息管理\\denglu.mdb;provider=Microsoft.Jet.OLEDB.4.0");
OleDbDataAdapter daAuthors = new OleDbDataAdapter("Select ID, Depart as 系部,Grade as 年级,clas as 班级,Curriculum as 科目,Teacher as 教师 From Teacher ", conn);
string myID = dataGrid1[dataGrid1.CurrentCell.RowNumber, 0].ToString().Trim();
conn.Open();
oleDbUpdateCommand1.Connection = conn;
daAuthors.UpdateCommand = oleDbUpdateCommand1;
oleDbUpdateCommand1.CommandText = "Update Teacher set Depart='" + this.textBox1.Text + " ' ,Grade='" + @textBox2.Text + "',clas=' " + @textBox3.Text + " ',Curriculum=' " + @textBox4.Text + " ',Teacher=' " + @textBox5.Text + " ' where ID= "+ int.Parse(myID);
daAuthors.UpdateCommand.ExecuteNonQuery();
daAuthors.Fill(ds, "denglu");
dataGrid1.DataSource = ds.Tables[0];
conn.Close();
}
仿照上面修改一下!!
[此贴子已经被作者于2007-3-29 17:40:15编辑过]
海鸽 is My Lover!!