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");
}
{
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 Database Update using OracleCommandBuilder
- System.Data.OracleClient.OracleCommandBuilder,如何生成UpdateCommand
- Oracle Report開發(1)--Oracle Report Builder
- C++Builder/Delphi 通过 ADO 存取Oracle 的 Blob 字段
- Oracle Forms builder —— text item
- SqlCommandBuilder笔记[原]
- 用SqlCommandBuilder 实现批量更新
- 基于Oracle Forms Builder 海洋地形信息系统设计与实现(三)
- Oracle.DataAccess.Client.OracleCommand.ExecuteNonQuery() 问题处理方法
- How to install oracle by Command Line Interface(CLI) in silent mode on Linux
- Oracle OneCommand
- Unable to validate using XSD: Your JAXP provider [oracle.xml.jaxp.JXDocumentBuilderFactory@1e0c9f64]
- 用SqlCommandBuilder 实现批量更新
- DataTable和SqlCommandBuilder
- asp.net 中使用sqlcommandbuilder
- 基于Oracle Forms Builder 海洋地形信息系统设计与实现(一)
- oracle 常用command
- Use SqlDataAdapter to update database, but SqlCommandBuilder required
- Oracle Reports Builder Sort by [select items]
- oracle command - creata database dbca & create network netca Demo