国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > 綜合 > 正文

在數(shù)據(jù)庫中開始一個事務

2024-07-21 02:22:54
字體:
來源:轉載
供稿:網(wǎng)友


下面的示例創(chuàng)建一個 oracleconnection 和一個 oracletransaction。它還演示了如何使用 begintransaction、commit 和 rollback 方法。

public void runoracletransaction(string myconnstring)
{
oracleconnection myconnection = new oracleconnection(myconnstring);
myconnection.open();

oraclecommand mycommand = myconnection.createcommand();
oracletransaction mytrans;

// start a local transaction
mytrans = myconnection.begintransaction(isolationlevel.readcommitted);
// assign transaction object for a pending local transaction
mycommand.transaction = mytrans;

try
{
mycommand.commandtext = "insert into dept (deptno, dname, loc) values (50, 'technology', 'denver')";
mycommand.executenonquery();
mycommand.commandtype= commandtype.storedprocedure;
mycommand.commandtext="prc_test";
mycommand.executenonquery();
mytrans.commit();
console.writeline("both records are written to database.");
}
catch(exception e)
{
mytrans.rollback();
console.writeline(e.tostring());
console.writeline("neither record was written to database.");
}
finally
{
myconnection.close();
}
}



發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 吉林市| 读书| 青河县| 宾川县| 镇江市| 红原县| 哈尔滨市| 南郑县| 泰州市| 平凉市| 修水县| 荥经县| 三河市| 遂平县| 光山县| 道真| 察隅县| 长垣县| 右玉县| 兰州市| 宿州市| 离岛区| 衡东县| 岗巴县| 乌海市| 仙桃市| 安仁县| 麻城市| 什邡市| 额尔古纳市| 江油市| 阳谷县| 桂平市| 方正县| 诏安县| 达日县| 铜陵市| 年辖:市辖区| 滦平县| 灵寿县| 壶关县|