最近2018中文字幕在日韩欧美国产成人片_国产日韩精品一区二区在线_在线观看成年美女黄网色视频_国产精品一区三区五区_国产精彩刺激乱对白_看黄色黄大色黄片免费_人人超碰自拍cao_国产高清av在线_亚洲精品电影av_日韩美女尤物视频网站

RELATEED CONSULTING
相關(guān)咨詢(xún)
選擇下列產(chǎn)品馬上在線(xiàn)溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
oracle事務(wù)庫(kù)怎么用,oracle數(shù)據(jù)庫(kù)常用操作

.NET中如何使用Oracle數(shù)據(jù)庫(kù)事務(wù)(2)

在C# 和 VB.NET 中使用數(shù)據(jù)庫(kù)事務(wù)您可以使用 OracleTransaction 類(lèi)的一個(gè)對(duì)象來(lái)表示一個(gè)事務(wù)。OracleTransaction 類(lèi)包含多個(gè)屬性,其中的兩個(gè)為 Connection(指定與事務(wù)關(guān)聯(lián)的數(shù)據(jù)庫(kù)連接)和 IsolationLevel(指定事務(wù)隔離級(jí)別);本文稍后將向您介紹更多有關(guān)事務(wù)隔離級(jí)別的內(nèi)容。 OracleTransaction 類(lèi)包含許多操控事務(wù)的方法。您可以使用 Commit() 方法永久提交 SQL 語(yǔ)句,并可以使用 Rollback() 撤銷(xiāo)這些語(yǔ)句。您還可以使用 Save() 在事務(wù)中設(shè)置一個(gè)保存點(diǎn)。 我現(xiàn)在將帶著您逐步完成兩個(gè)示例程序 ― 一個(gè)用 C# 編寫(xiě) (TransExample1.cs),另一個(gè)用 VB.NET 編寫(xiě) (TransExample1.vb)。這些程序演示了如何執(zhí)行一個(gè)包含了兩條 INSERT 語(yǔ)句的事務(wù)。第一條 INSERT 語(yǔ)句將在表 product_types 中添加一行,第二條將在表 products 中添加一行。 導(dǎo)入命名空間以下C# 程序語(yǔ)句指定在程序中使用 System 和 Oracle.DataAcess.Client 命名空間: using System; using Oracle.DataAccess.Client;下面是等價(jià)的 VB.NET 語(yǔ)句: Imports System Imports Oracle.DataAccess.ClientOracle.DataAccess.Client 命名空間是 ODP.NET 的一部分,它包含許多類(lèi),其中有OracleConnection、OracleCommand 和 OracleTransaction。示例程序用到了這些類(lèi)。 第1 步 創(chuàng)建一個(gè) OracleConnection 對(duì)象連接到 Oracle 數(shù)據(jù)庫(kù),然后打開(kāi)該連接。 在C# 中: OracleConnection myOracleConnection = new OracleConnection( "User Id=store;Password=store;Data Source=ORCL" ); myOracleConnection.Open();在VB.NET 中: Dim myOracleConnection As New OracleConnection( _ "User Id=store;Password=store;Data Source=ORCL") myOracleConnection.Open()User Id 和 Password 屬性指定了您所要連接到的模式的數(shù)據(jù)庫(kù)用戶(hù)和口令。Data Source 屬性指定了數(shù)據(jù)庫(kù)的 Oracle Net 服務(wù)名稱(chēng);初始數(shù)據(jù)庫(kù)的默認(rèn)服務(wù)名稱(chēng)為 ORCL。如果您使用的不是初始數(shù)據(jù)庫(kù),或者您的服務(wù)名稱(chēng)不同,那么您需要在程序中修改 Data Source 屬性的設(shè)置。 第2 步 創(chuàng)建一個(gè) OracleTransaction 對(duì)象,然后調(diào)用 OracleConnection 對(duì)象的 BeginTransaction() 方法啟動(dòng)事務(wù)。 在C# 中: OracleTransaction myOracleTransaction = myOracleConnection.BeginTransaction(); In VB.NET: Dim myOracleTransaction As OracleTransaction = _ myOracleConnection.BeginTransaction()第3 步 創(chuàng)建一個(gè) OracleCommand 對(duì)象,用于存儲(chǔ) SQL 語(yǔ)句。 在C# 中: OracleCommand myOracleCommand = myOracleConnection.CreateCommand();在VB.NET 中: Dim myOracleCommand As OracleCommand = myOracleConnection.CreateCommand因?yàn)镺racleCommand 對(duì)象使用 OracleConnection 對(duì)象的 CreateCommand() 方法創(chuàng)建的,所以它自動(dòng)使用在第 2 步中為 OracleConnection 對(duì)象設(shè)置的事務(wù)。 第4 步 將OracleCommand 對(duì)象的 CommandText 屬性設(shè)為向表 product_types 中添加一行的第一條 INSERT 語(yǔ)句。 在C# 中: myOracleCommand.CommandText = "INSERT INTO product_types (" + " product_type_id, name" + ") VALUES (" + " 3, 'Magazine'" + ")";在VB.NET 中: myOracleCommand.CommandText = _ "INSERT INTO product_types (" _ " product_type_id, name" _ ") VALUES (" _ " 3, 'Magazine'" _ ")"

創(chuàng)新互聯(lián)于2013年創(chuàng)立,先為尚志等服務(wù)建站,尚志等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢(xún)服務(wù)。為尚志企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問(wèn)題。

求問(wèn)在.NET中如何使用Oracle數(shù)據(jù)庫(kù)事務(wù) (5)

您可以使用 OracleTransaction 類(lèi)的 Save() 方法在事務(wù)中設(shè)置保存點(diǎn)。 如果您有一個(gè)非常長(zhǎng)的事務(wù)并且希望能夠僅回滾到某個(gè)特定的時(shí)間點(diǎn),那么您可能要使用保存點(diǎn)。例如,您可能想對(duì) 10 個(gè)產(chǎn)品做一些更改,然后設(shè)置一個(gè)保存點(diǎn),然后再對(duì)另 10 個(gè)產(chǎn)品做更改;如果您在進(jìn)行第二批更改時(shí)出現(xiàn)了錯(cuò)誤,那么您可以回滾至保存點(diǎn),使您的第一批更改原封不動(dòng)。 我將帶您逐步完成演示如何使用保存點(diǎn)的 C# (TransExample2.cs) 示例程序和 VB.NET (TransExample2.vb) 示例程序中的相關(guān)新步驟。這些程序向表 products 中添加一行,設(shè)置一個(gè)保存點(diǎn),向表 products 中添加另一行,回滾至保存點(diǎn),然后從表 products 中讀取這些行。在回滾至保存點(diǎn)后,只有添加到表 products 中的第一行保留了下來(lái):第二行將已被刪除。 第1 到第 3 步與“在 C# 和 VB.NET 中使用數(shù)據(jù)庫(kù)事務(wù)”部分中所示的步驟相同,因此在這里將其省略。 第4 步 向表products 中添加一行,該行的產(chǎn)品 ID 為 6。 在C# 中: myOracleCommand.CommandText = "INSERT INTO products (" + " product_id, product_type_id, name, description, price" + ") VALUES (" + " 6, 2, 'Man from Another World', ' Man from Venus lands on Earth', 24.99" + ")"; myOracleCommand.ExecuteNonQuery();在VB.NET 中: myOracleCommand.CommandText = _ "INSERT INTO products (" _ " product_id, product_type_id, name, description, price" _ ") VALUES (" _ " 6, 2, 'Man from Another World', 'Man from Venus lands on Earth', 24.99" _ ")" myOracleCommand.ExecuteNonQuery()第5 步 使用OracleTransaction 的 Save() 方法設(shè)置一個(gè)名為 SaveProduct 的保存點(diǎn)。 在C# 中: myOracleTransaction.Save("SaveProduct");在VB.NET 中: myOracleTransaction.Save("SaveProduct")第6 步 向表products 中添加另一行,該行的產(chǎn)品 ID 為 7。 在C# 中: myOracleCommand.CommandText = "INSERT INTO products (" + " product_id, product_type_id, name, description, price" + ") VALUES (" + " 7, 2, 'Z-Files', 'Mysterious stories', 14.99" + ")"; myOracleCommand.ExecuteNonQuery();在VB.NET 中: myOracleCommand.CommandText = _ "INSERT INTO products (" _ " product_id, product_type_id, name, description, price" _ ") VALUES (" _ " 7, 2, 'Z-Files', 'Mysterious stories', 14.99" _ ")" myOracleCommand.ExecuteNonQuery()第7 步 回滾到先前在第 5 步中設(shè)置的 SaveProduct 保存點(diǎn)。 在C# 中: myOracleTransaction.Rollback("SaveProduct");在VB.NET 中: myOracleTransaction.Rollback("SaveProduct")完成回滾后,在第 6 步中添加的第二行已被刪除,而在第 4 步中添加的第一行保留了下來(lái)。 TransExample2.cs 和 TransExample2.vb 中剩下的步驟顯示表 products 的內(nèi)容,回滾整個(gè)事務(wù)并從數(shù)據(jù)庫(kù)斷開(kāi)。 用于Microsoft Transaction Server 的 Oracle 事務(wù)服務(wù)的快速說(shuō)明。Microsoft Transaction Server 是一個(gè)運(yùn)行在互聯(lián)網(wǎng)或網(wǎng)絡(luò)服務(wù)器上的專(zhuān)有事務(wù)處理系統(tǒng)。Microsoft Transaction Server 為客戶(hù)端計(jì)算機(jī)部署和管理應(yīng)用程序和數(shù)據(jù)庫(kù)事務(wù)請(qǐng)求。 Microsoft Transaction Server 是以服務(wù)器為中心的三層體系結(jié)構(gòu)模型的一個(gè)組件。這種方法實(shí)現(xiàn)了將應(yīng)用程序的表示、業(yè)務(wù)邏輯和數(shù)據(jù)元素清晰地分布到在一個(gè)網(wǎng)絡(luò)中連接的不同計(jì)算機(jī)上。無(wú)需專(zhuān)門(mén)集成,您就可以在與 Oracle 數(shù)據(jù)庫(kù)服務(wù)器 8.0.6 版或更高版本連接的 Microsoft Transaction Server 中部署一個(gè)組件,但首先您必須安裝 Oracle Services for Microsoft Transaction Server。 結(jié)論在本文中,您系統(tǒng)學(xué)習(xí)了在 .NET 程序中使用數(shù)據(jù)庫(kù)事務(wù)。 (T004)

Oracle中事務(wù)怎么使用 ,什么時(shí)候使用事物

事務(wù)是為了保證數(shù)據(jù)的完整性而設(shè)置的,在使用事務(wù)時(shí),如果你是使用程序進(jìn)行控制的話(huà),一般都會(huì)自動(dòng)提交事務(wù)的,需要手動(dòng)進(jìn)行事務(wù)的操作的是在進(jìn)行批處理的時(shí)候,為了保證數(shù)據(jù)要么一起成功要么一起失敗,在開(kāi)始數(shù)據(jù)的插入或者刪除之前,要把事務(wù)的自動(dòng)提交改為false,然后才能執(zhí)行相關(guān)的SQL語(yǔ)句,當(dāng)SQL無(wú)異常全部執(zhí)行完以后,再手動(dòng)提交就可以了


網(wǎng)站名稱(chēng):oracle事務(wù)庫(kù)怎么用,oracle數(shù)據(jù)庫(kù)常用操作
文章轉(zhuǎn)載:http://fisionsoft.com.cn/article/hcjiep.html