然后我的一个DataGridView.DataSource是其中的一个表。
为什么对DataGridView修改后,然后更新,数据库中没有反应using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using dataSetTest2.DeviceBasesDataSetTableAdapters;namespace dataSetTest2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        BASE_INFORMATIONTableAdapter tableAdapter;
        DeviceBasesDataSet dataSet;        private void Form1_Load(object sender, EventArgs e)
        {
            dataSet = new DeviceBasesDataSet();            tableAdapter = new BASE_INFORMATIONTableAdapter();
            tableAdapter.Fill(dataSet.BASE_INFORMATION);            dataGridView1.DataSource = dataSet.BASE_INFORMATION;
        }        private void buttonUpdate_Click(object sender, EventArgs e)
        {
            tableAdapter.Update(dataSet.BASE_INFORMATION);
        }
    }
}

解决方案 »

  1.   

    我知道是因为数据没有写回dataTable
    想知道有没有什么方便的方法
      

  2.   

    SqlDataAdapter sdaAdapter = null;sdaAdapter.Update(ds, "customers");
      

  3.   

    呃,偶不是这个意思,我的dataGridView的数据没有写到DataTable中
    我想在修改的时候把DataGridView中新添加的数据写到DataTable中
      

  4.   

    晕,帮我看看,为什么更新不了数据库了...

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using dataSetTest2.DeviceBasesDataSetTableAdapters;
    using System.Data.OleDb;namespace dataSetTest2
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            BASE_INFORMATIONTableAdapter tableAdapter;
            DeviceBasesDataSet dataSet;        private void Form1_Load(object sender, EventArgs e)
            {
                dataSet = new DeviceBasesDataSet();            tableAdapter = new BASE_INFORMATIONTableAdapter();
                tableAdapter.Fill(dataSet.BASE_INFORMATION);            dataGridView1.DataSource = dataSet.BASE_INFORMATION;
            }        private void buttonUpdate_Click(object sender, EventArgs e)
            {
                DataRow dataRow = dataSet.BASE_INFORMATION.NewRow();            dataRow[0] = "2100";
                dataRow[1] = "Ericsson";
                dataRow[2] = "Misc";
                dataSet.BASE_INFORMATION.Rows.Add(dataRow);            dataSet.AcceptChanges();
                tableAdapter.Update(dataSet);            
            }    }
    }