Csharp/C Sharp by API/System.Data.OleDb/OleDbDataAdapter

Материал из .Net Framework эксперт
Версия от 12:10, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

new OleDbDataAdapter

 
using System;
using System.Data;
using System.Data.OleDb;

    public class UpdatingADataSource
    {
        static void Main(string[] args)
        {
            OleDbConnection MyConnection = new OleDbConnection(@"Provider=Microsft.Jet.OLEDB.4.0; Data Source = c:\MyAccessDB.mdb");
            OleDbDataAdapter MyAdapter = new OleDbDataAdapter("SELECT Column1, Column2, Column3 FROM MyTable", MyConnection);
            DataSet MyDataSet = new DataSet();
            MyAdapter.Fill(MyDataSet, "MyTable");
            MyDataSet.Tables[0].Rows[3]["Column3"] = "Test";
            OleDbCommandBuilder MyBuilder = new OleDbCommandBuilder(MyAdapter);
            MyAdapter.Update(MyDataSet.Tables[0]);
        }
    }


OleDbDataAdapter.Fill

 
using System;
using System.Data;
using System.Data.OleDb;

    public class UpdatingADataSource
    {
        static void Main(string[] args)
        {
            OleDbConnection MyConnection = new OleDbConnection(@"Provider=Microsft.Jet.OLEDB.4.0; Data Source = c:\MyAccessDB.mdb");
            OleDbDataAdapter MyAdapter = new OleDbDataAdapter("SELECT Column1, Column2, Column3 FROM MyTable", MyConnection);
            DataSet MyDataSet = new DataSet();
            MyAdapter.Fill(MyDataSet, "MyTable");
            MyDataSet.Tables[0].Rows[3]["Column3"] = "Test";
            OleDbCommandBuilder MyBuilder = new OleDbCommandBuilder(MyAdapter);
            MyAdapter.Update(MyDataSet.Tables[0]);
        }
    }