谢谢你呀!
真有点不好意思拉!那么麻烦你!拜托了!
[紧急求助!!]数据库高手们:
我想修改数据库的内容,修改的是 dataGrid1指定的行为myID,ID字段在teacher数据库是第一个字段
修改语句如下:出错的地方是红色标记的地方
不知道是怎么回事啊????
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 * 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= myID ";
daAuthors.UpdateCommand.ExecuteNonQuery();
daAuthors.Fill(ds, "denglu");
dataGrid1.DataSource = ds.Tables[0];
conn.Close();
}
[此贴子已经被作者于2007-3-14 15:15:38编辑过]