Access to DataTable

       conn.Open ();                  
                    the OleDbDataAdapter new new Bada = the OleDbDataAdapter ( "from the SELECT *" + cmdText The, conn); // establish a DataAdapter object
                    OleDbCommandBuilder cb = new OleDbCommandBuilder (Bada) ; // here CommandBuilder object must not forget, general It is written in the DataAdapter defined later
                    cb.QuotePrefix = "[";
                    cb.QuoteSuffix = "]";
                    DataSet DataSet new new DS = (); // build DataSet object
                    Bada.Fill (ds, "demo") ; // filled the DataSet
                    DataTable ds.Tables dt = [ "Demo"]; // create a DataTable object, easy to operate
                    the foreach (in the DataRow tempRow dt1.Rows)
                    {
                        the DataRow dt.NewRow DR = ();
                        dr.ItemArray = tempRow.ItemArray; // copy row
                        dt.Rows.Add (DR);
                    }
                    Bada.Update (DS, "Demo"); // update the database with a method of the Update DataAdapter ()

Guess you like

Origin www.cnblogs.com/ruiyuan/p/11410406.html