Update the data source method 1, Command object update required Properties: Connection Contains Detail of the Data Warehouse Connection CommandText To Run the Type SQL Character or Store Name of the SQL Character or Store SQL TableDirect Indicates Table Name StoredProcedure Represents Storage Process Name Parameters Parameters object A collection of objects
2, DataAdapter object Note DataAdapter and Command's difference? >> Command is mainly used to run commands >> DataAPter is mainly used to provide a storage space for multiple commands, providing bidirectional interactions between data warehouses and DataSets. Oh, a Command object can only handle queries, add, delete, and modify one of the DataAdapter store four Command object properties as follows SelectCommand, UpdateCommand, INSERTCOMMAND, DeleteCommand
3, CommandBuilder objects OleDbCommandBuilder objBuilder objBuilder = new OleDbCommandBuilder (DataAdapter) indicates to the command generator may get to where SelectCommand, to create another command DataAdapter.UpdateCommand = objBuilder.GetUpdateCommand ();. DataAdapter.InsertCommand = objBuilder.GetInsertCommand () DataAdapter.deleteCommand = objbuilder.getDeleteCommand (); Note In this case, selectcommand must have a primary key field.
4. DataAdapter.Update () DataAdapter.Update (DataSet, "TablesName"); for example, the following code ensures that the deleted row in the table is processed, and then process the updated row and process the inserted row. [C #] DataTable Updtable = Custds.tables ["Customers"];
// first process deletes. Custda.Update (Updtable.select (Null, Null, DataViewRowState.deleted);
// next process updates. Custda.Update (Updtable.select (Null, Null, DataViewrowState.ModifiedCurrent);
// Finally, process inserts custDA.Update (updTable.Select (null, null, DataViewRowState.Added));. DataViewRowState view in which the operation attribute comprising Deleted, ModifiedCurrent, Added, Unchanged, etc. Thus, the update data warehouse complete.
[2003-05-28] Using the stored procedure stored procedure is similar to a function in the code, it is stored on the data server and has a name. Why use stored procedures? 1. The huge complex SQL statement affects the program code reading 2. The stored procedure processed by the database server is faster and more efficient than the SQL statement directly, it is necessary to note that the CommandType is set to StoredProccess CommandText for the stored procedure Name EG: Objcmd.commandtext = "[Sales By Category]"; Objcmd.commandType = CommandType.StoreProcedure; Using XML Due to the ADO.NET design, it considers XML, which processing XML data is like these data comes from a database. 1. Write XML file objadapter.fill (objDataSet, "EMPLOYEES"); // Fill result set ObjdataSet.writeXML (Server.Mappath ("Employees.xml")); // Write to XML file Note Two points: 1 First, I first use the DataSet WriteXML () method, extract information from the DataSet and format XML 2, and server.mAppath () represents the generated file path, pointing to the current application directory 2, read the XML file ObjDataSet.Readxml (Server. Mappath ("Employees.xml")); 3, convert XML to string strXml, strschema strxml = objDataSet.getxml () strschema = objDataSet.Getxmlschema () 4, once XML read into DataSet He is also from database The data read in the middle does not have any difference, or any of the previous operations, ultimately as long as the result set Dataset is written to the XML or database