国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 射阳县| 东安县| 宾阳县| 西城区| 会理县| 钟山县| 杨浦区| 通州市| 墨江| 大冶市| 西乡县| 阿克陶县| 台州市| 成武县| 江阴市| 徐水县| 北碚区| 文昌市| 黑龙江省| 邢台县| 社旗县| 郎溪县| 卓尼县| 龙山县| 巴林右旗| 武陟县| 万盛区| 开封市| 东乡县| 辛集市| 杂多县| 泉州市| 齐齐哈尔市| 张家界市| 界首市| 民乐县| 金华市| 巴彦淖尔市| 翼城县| 泰宁县| 涿鹿县|