using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OracleClient;namespace AdoStd
{
    public partial class Form1 : Form
    {
        string _connectString = @"Data Source = orcl;User Id =system;password = admin;";
        OracleDataAdapter _da = new OracleDataAdapter();
        DataSet _ds = new DataSet();
        OracleConnection _conn = new OracleConnection();
        
        public Form1()
        {
            InitializeComponent();
        }        private void Form1_Load(object sender, EventArgs e)
        {
            _conn.ConnectionString = _connectString;
            _conn.Open();
            _da = new OracleDataAdapter("SELECT * FROM food_class_dict", _conn);
                _da.Fill(_ds);
                dataGridView1.DataSource = _ds.Tables[0];
                _conn.Close();
        }        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            //DataRow _dateRow = _ds.Tables[0].NewRow();
            //_dateRow["Class_Code"] = "wo";
            //_dateRow["Class_Name"] = "wo";
            //_ds.Tables[0].Rows.Add(_dateRow);
            //dataGridView1.DataSource = _ds.Tables[0];            Save();
        }
        private void Save()
        {
            //保存
            dataGridView1.EndEdit();            _conn.ConnectionString = _connectString;
            _conn.Open();            OracleCommandBuilder _cmd = new OracleCommandBuilder(_da);
            _da.Update(_ds.Tables[0]);        }        private void button1_Click(object sender, EventArgs e)
        {
            Save();
        }    }
}太奇怪了,我在工具栏上的按钮调保存函数不成功(不能更新表),在普通的按钮上调保存函数确成功了(表成功更新!),这是怎么回事!是不是工具栏上需要设置什么??