OracleCommandBuilder

public static void BuilderUpdate(string connStr)
{
string cmdStr = "SELECT EMPNO, EMPNAME, JOBDESCRIPTION FROM EMPINFO";

//create the adapter with the selectCommand txt and the
//connection string
OracleDataAdapter adapter = new OracleDataAdapter(cmdStr, connStr);

//get the connection from the adapter
OracleConnection connection = adapter.SelectCommand.Connection;

//create the builder for the adapter to automatically generate
//the Command when needed
OracleCommandBuilder builder = new OracleCommandBuilder(adapter);

//Create and fill the DataSet using the EMPINFO
DataSet dataset = new DataSet();

adapter.Fill(dataset, "EMPINFO");

//Get the EMPINFO table from the dataset
DataTable table = dataset.Tables["EMPINFO"];

//Get the first row from the EMPINFO table
DataRow row0 = table.Rows[0];

//update the job description in the first row
row0["JOBDESCRIPTION"] = "MANAGER";

//Now update the EMPINFO using the adapter, the job description
//of ’KING’ is changed to ’MANAGER’
//The OracleCommandBuilder will create the UpdateCommand for the
//adapter to update the EMPINFO table
adapter.Update(dataset, "EMPINFO");
}

你可能感兴趣的:(Oracle,Data,Provider,for,.NET,学习笔记,dataset,table,manager,string,command)