OracleDataAdapter Class
2004-11-18 10:29
459 查看
// C#
public static void AdapterUpdate(string connStr)
{
string cmdStr = "SELECT EMPNO, EMPNAME, SALARY 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 UpdateCommand object for updating the EMPINFO table
//from the dataset
adapter.UpdateCommand = new OracleCommand(
"UPDATE EMPINFO SET SALARY = "+ " :iSALARY where EMPNO = :iEMPNO", connection);
adapter.UpdateCommand.Parameters.Add(":iSALARY", OracleDbType.Double,0, "SALARY");
adapter.UpdateCommand.Parameters.Add(":iEMPNO", OracleDbType.Int16,0, "EMPNO");
//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 salary in the first row
row0["SALARY"] = 99999.99;
//Now update the EMPINFO using the adapter, the salary
//of ’KING’ is changed to 99999.99
adapter.Update(dataset, "EMPINFO");
}
public static void AdapterUpdate(string connStr)
{
string cmdStr = "SELECT EMPNO, EMPNAME, SALARY 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 UpdateCommand object for updating the EMPINFO table
//from the dataset
adapter.UpdateCommand = new OracleCommand(
"UPDATE EMPINFO SET SALARY = "+ " :iSALARY where EMPNO = :iEMPNO", connection);
adapter.UpdateCommand.Parameters.Add(":iSALARY", OracleDbType.Double,0, "SALARY");
adapter.UpdateCommand.Parameters.Add(":iEMPNO", OracleDbType.Int16,0, "EMPNO");
//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 salary in the first row
row0["SALARY"] = 99999.99;
//Now update the EMPINFO using the adapter, the salary
//of ’KING’ is changed to 99999.99
adapter.Update(dataset, "EMPINFO");
}
相关文章推荐
- 未能从程序集“Oracle.ManagedDataAccess”加载 “OracleInternal.Common.ConfigBaseClass”
- {"未能从程序集“Oracle.ManagedDataAccess, OracleInternal.Common.ConfigBaseClass”。":"OracleInternal.Common.C
- .Net中使用OracleDataAdapter
- oleDbDataAdapter和oracleDataAdapter适配器的性能差异
- 在使用OracleDataAdapterFill(Dataset)方法时报错:指定的参数已超出有效值的范围
- OracleDataAdapter.update 问题
- ADO.NET_07_OracleDataAdapter
- OracleDataAdapter.Fill()处于无限等待中 【已解决】
- .Net中使用OracleDataAdapter
- System.Data.OracleClient.OracleCommand 和OracleDataAdapter过时
- sqlconnection,sqldataadapter,sqlcommand
- BizTalk Adapter Pack for Oracle:Connecting to the LOB system has failed.ORA-1017: invalid name/password
- sqlDataAdapter和SqlCommand的区别
- 设计模式之美:Private Class Data(私有类数据)
- 系统找不到文件C:\ProgramData\Oracle\Java\javapath\java.exe
- SqlDataAdapter 更新插入 与 InsertBulkCopy
- SqlDataAdapter 批量更新数据库表
- Data Guard Physical Standby Setup in Oracle Database 11g Release 2
- oracle The Network Adapter could not establish the connection
- SqlDataAdapter 删除数据的细节问题