当前位置:编程学习 > C#/ASP.NET >>

c# 怎么用button更新DataGridView的数据到access

? --------------------编程问答-------------------- 写一个dataAdaper.update --------------------编程问答--------------------
static private DataSet CreateCommandAndUpdate(
    string connectionString,
    string queryString)
{
    DataSet dataSet = new DataSet();

    using (OleDbConnection connection =
               new OleDbConnection(connectionString))
    {
        connection.Open();
        OleDbDataAdapter dataAdapter =
            new OleDbDataAdapter();
        dataAdapter.SelectCommand =
            new OleDbCommand(queryString, connection);
        OleDbCommandBuilder commandBuilder =
            new OleDbCommandBuilder(dataAdapter);

        dataAdapter.Fill(dataSet);

        // Code to modify data in the DataSet here.

        //Without the OleDbCommandBuilder this line would fail.
        dataAdapter.Update(dataSet);
    }
    return dataSet;
}

--------------------编程问答-------------------- 试一试
补充:.NET技术 ,  C#
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,