请帮我找错误!红色的两行应该是有问题的,就是自动获得SQL语句用不好(OleDbCommandBuilder),请高手指点
try
{
oleConn.Open();
//新键数据集
DataSet objDataSet = new DataSet();
//初始化数据适配器
oleDa = new OleDbDataAdapter("select * from StudentsInfo", oleConn);
//填充数据集
oleDa.Fill(objDataSet, "StudentsInfo");
//创建显示insert命令
oleDa.InsertCommand = oleConn.CreateCommand();
OleDbCommandBuilder oleCB = new OleDbCommandBuilder(oleDa);
oleDa.InsertCommand.CommandText =oleCB.ToString();
//创建数据表
DataTable objDataTable = new DataTable();
objDataSet.Tables.Add(objDataTable);
DataRow objDataRow = objDataSet.Tables[0].NewRow();
objDataRow["StudentsNo"] = txtNo.Text.Trim();
objDataRow["StudentsName"] = txtName.Text.Trim();
objDataRow["StudentsCur"] = txtCurricula.Text.Trim();
objDataRow["StudentsScore"] = txtScore.Text.Trim();
objDataSet.Tables[0].Rows.Add(objDataRow);
oleDa.Update(objDataSet,"StudentsInfo");
objDataSet.AcceptChanges();
MessageBox.Show("保存成功!");
}
catch (OleDbException ox)
{
MessageBox.Show(ox.Message);
}
catch (Exception ox)
{
MessageBox.Show(ox.Message);
}
finally
{
oleConn.Close();
}