新聞中心
VB.NET還是比較常用的,于是我研究了一下VB.NET使用OracleTransaction對(duì)象,在這里拿出來和大家分享一下,希望對(duì)大家有用。

創(chuàng)新互聯(lián)總部坐落于成都市區(qū),致力網(wǎng)站建設(shè)服務(wù)有成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)、網(wǎng)絡(luò)營(yíng)銷策劃、網(wǎng)頁設(shè)計(jì)、網(wǎng)站維護(hù)、公眾號(hào)搭建、重慶小程序開發(fā)、軟件開發(fā)等為企業(yè)提供一整套的信息化建設(shè)解決方案。創(chuàng)造真正意義上的網(wǎng)站建設(shè),為互聯(lián)網(wǎng)品牌在互動(dòng)行銷領(lǐng)域創(chuàng)造價(jià)值而不懈努力!
VB.NET使用OracleTransaction對(duì)象需要注意的幾點(diǎn):
1)你需要在你整個(gè)事務(wù)執(zhí)行中只能有***OracleConnection,也就是說如果你事務(wù)處理過程中如果需要與數(shù)據(jù)庫(kù)的操作都只能在這***的Command中執(zhí)行,類似于:
- imgCommand.CommandText = sSQL
- imgCommand.ExecuteNonQuery()或其他操作
若你新建一個(gè)連接執(zhí)行其他數(shù)據(jù)庫(kù)操作的話,整個(gè)事務(wù)過程就會(huì)拋出異常
2)如果你需要在你SQL語句中加入?yún)?shù),則你必須在你執(zhí)行完提交或相關(guān)數(shù)據(jù)庫(kù)操作之后將其Command的參數(shù)清空,下邊舉一個(gè)實(shí)際的項(xiàng)目里的事務(wù)函數(shù):
- '''
- ''' 保存熱點(diǎn)文本文件信息到數(shù)據(jù)庫(kù)
- '''
- Private Function SaveTextFile()Function SaveTextFile() As Boolean
- Dim sSQl As String
- sSQl = "select type_id from sys_file_type where file_extname='TXT'"
- Try
- imgCommand.CommandText = sSQl
- Dim typeID As Int32 = Convert.ToInt32(imgCommand.ExecuteScalar()) '文件類型
- '讀取文本信息
- Dim Textblob() As Byte = GetText()
- sSQl = "insert into t_watch_textcontent(image_id,text_content,type_id)
values(:imageid,:textcontent,:typeid)"- '增添SQL參數(shù)
- Dim Param As OracleClient.OracleParameter
- Param = New OracleClient.OracleParameter("imageid", sNewImageID)
- imgCommand.Parameters.Add(Param)
- Param = New OracleClient.OracleParameter("textcontent", Textblob)
- imgCommand.Parameters.Add(Param)
- Param = New OracleClient.OracleParameter("typeid", typeID)
- imgCommand.Parameters.Add(Param)
- '提交信息
- imgCommand.CommandText = sSQl
- If imgCommand.ExecuteNonQuery() > 0 Then
- bResult = True
- '關(guān)鍵是這里,需要你手動(dòng)清除參數(shù)
- imgCommand.Parameters.Clear()
- End If
- Catch ex As Exception
- Me.ExceptionMessage = ex
- bResult = False
- End Try
- Return bResult
- End Function
以上介紹VB.NET使用OracleTransaction對(duì)象。
分享題目:VB.NET使用OracleTransaction對(duì)象深入剖析
URL鏈接:http://m.fisionsoft.com.cn/article/cdpshgc.html
其他資訊
- C語言實(shí)現(xiàn)數(shù)據(jù)庫(kù)備份和還原(c實(shí)現(xiàn)數(shù)據(jù)庫(kù)的備份和還原)
- 探索Linux系統(tǒng)端口啟用實(shí)現(xiàn)方法(linux查看端口啟用)
- Dede數(shù)據(jù)庫(kù)用戶:管理您的網(wǎng)站數(shù)據(jù)(dede數(shù)據(jù)庫(kù)用戶)
- 美國(guó)IIDATC機(jī)房怎么樣?美國(guó)IIDATC機(jī)房速度評(píng)測(cè)(美國(guó)cn2機(jī)房)
- 如何破解WindowsServer2012密碼?(windows2012破解)


咨詢
建站咨詢
