您的位置:首页 > 数据库 > Oracle

OracleCommandBuilder

2004-11-18 09:17 489 查看
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");
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: