c# 修改错误
private void button4_Click(object sender, EventArgs e){
try
{
int a = this.dataGrid1.CurrentCell.RowNumber;
string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\c#\\book.mdb";
OleDbConnection myConn = new OleDbConnection(strCon);
myConn.Open();
DataSet myDataSet = new DataSet();
OleDbCommand command = new OleDbCommand("SELECT * FROM book order by 编号 ", myConn);
OleDbDataAdapter ads = new OleDbDataAdapter(command);
ads.Fill(myDataSet);
string strCom = "UPDATE book set 书名='" + myDataSet.Tables["book"].Rows[a][1] + "',作者='" + myDataSet.Tables["book"].Rows[a][2] + "',价格=" + myDataSet.Tables["book"].Rows[a][3] + ",书架号=" + myDataSet.Tables["book"].Rows[a][4] + " where 编号=" + myDataSet.Tables["book"].Rows[a][0] +"";
OleDbCommand inst = new OleDbCommand(strCom, myConn);
inst.ExecuteNonQuery();
OleDbDataAdapter myCommand = new OleDbDataAdapter("SELECT *FROM book order by 编号", myConn);
myDataSet.Clear();
myCommand.Fill(myDataSet, "book");
this.dataGrid1.DataSource = myDataSet.Tables["book"];
myConn.Close();
}
catch (Exception x)
{
MessageBox.Show("错误" + x.ToString(), "error"
}
}