数据库更新时需要可更新的查询是什么原因啊?
private void button2_Click(object sender, EventArgs e)
{
OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "/" + "DB_student.mdb");
aConnection.Open();
string strName;
string strName1 = "update Error set AbsoE =(select BasicPoint.Bx-SurveyPoint.Sx from BasicPoint,SurveyPoint where BasicPoint.BG=" + textBox5.Text + " and SurveyPoint.SG=" + textBox5.Text + ") where Error.EG=" + textBox5.Text;
OleDbDataAdapter myadapter3 = new OleDbDataAdapter(strName1, aConnection);
DataSet ds3 = new DataSet();
myadapter3.Fill(ds3);
运行之后总说需要一个可更新的查询,权限也修改了,可是还是显示这个问题,请各位看看有什么问题吧
------解决方案--------------------修改数据应该这么写:
string strName1 = "update Error set AbsoE =(select BasicPoint.Bx-SurveyPoint.Sx from BasicPoint,SurveyPoint where BasicPoint.BG=" + textBox5.Text + " and SurveyPoint.SG=" + textBox5.Text + ") where Error.EG=" + textBox5.Text;
OleDbCommand cmd = new OleDbCommand(strName1, aConnection);
cmd.ExecuteNonQuery();
你那个Fill方法是查询数据用的。