OracleDataAdapter Class

xiaoxiao2021-03-06  68

// 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 stringoracledataadapter Adapter = New OracleDataAdapter (cmdstr, connStr);

// Get the connection from the adapteroraclectConnection connection = adapter.selectCommand.connection;

// create the UpdateCommand object for updating the EMPINFO table // from the datasetadapter.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 EmpinfodataSet DataSet = new dataset (); adapter.fill (Dataset, "Empinfo");

// Get the Empinfo Table from The DatasetDataTable Table = Dataset.tables ["Empinfo"];

// Get the first row from the Empinfo TableDataRow Row0 = Table.Rows [0];

// update the salary in the first rowrow0 ["salary"] = 99999.99;

// now Update The Empinfo Using The Adapter, The Salarit // of 'King' Is Changd to 99999.99Adapter.Update (Dataset, "Empinfo");}

转载请注明原文地址:https://www.9cbs.com/read-90491.html

New Post(0)