日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

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

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
VB.NET使用OracleTransaction對象深入剖析

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

創(chuàng)新互聯(lián)總部坐落于成都市區(qū),致力網(wǎng)站建設(shè)服務(wù)有成都網(wǎng)站設(shè)計、成都網(wǎng)站建設(shè)、網(wǎng)絡(luò)營銷策劃、網(wǎng)頁設(shè)計、網(wǎng)站維護(hù)、公眾號搭建、重慶小程序開發(fā)、軟件開發(fā)等為企業(yè)提供一整套的信息化建設(shè)解決方案。創(chuàng)造真正意義上的網(wǎng)站建設(shè),為互聯(lián)網(wǎng)品牌在互動行銷領(lǐng)域創(chuàng)造價值而不懈努力!

VB.NET使用OracleTransaction對象需要注意的幾點(diǎn):

1)你需要在你整個事務(wù)執(zhí)行中只能有***OracleConnection,也就是說如果你事務(wù)處理過程中如果需要與數(shù)據(jù)庫的操作都只能在這***的Command中執(zhí)行,類似于:

 
 
 
  1. imgCommand.CommandText = sSQL
  2. imgCommand.ExecuteNonQuery()或其他操作

若你新建一個連接執(zhí)行其他數(shù)據(jù)庫操作的話,整個事務(wù)過程就會拋出異常

2)如果你需要在你SQL語句中加入?yún)?shù),則你必須在你執(zhí)行完提交或相關(guān)數(shù)據(jù)庫操作之后將其Command的參數(shù)清空,下邊舉一個實際的項目里的事務(wù)函數(shù):

 
 
 
  1. ''' 
  2. ''' 保存熱點(diǎn)文本文件信息到數(shù)據(jù)庫
  3. ''' 
  4. Private Function SaveTextFile()Function SaveTextFile() As Boolean
  5. Dim sSQl As String
  6. sSQl = "select type_id from sys_file_type where file_extname='TXT'"
  7. Try
  8. imgCommand.CommandText = sSQl
  9. Dim typeID As Int32 = Convert.ToInt32(imgCommand.ExecuteScalar()) '文件類型
  10. '讀取文本信息
  11. Dim Textblob() As Byte = GetText()
  12. sSQl = "insert into t_watch_textcontent(image_id,text_content,type_id) 
    values(:imageid,:textcontent,:typeid)"
  13. '增添SQL參數(shù)
  14. Dim Param As OracleClient.OracleParameter
  15. Param = New OracleClient.OracleParameter("imageid", sNewImageID)
  16. imgCommand.Parameters.Add(Param)
  17. Param = New OracleClient.OracleParameter("textcontent", Textblob)
  18. imgCommand.Parameters.Add(Param)
  19. Param = New OracleClient.OracleParameter("typeid", typeID)
  20. imgCommand.Parameters.Add(Param)
  21. '提交信息
  22. imgCommand.CommandText = sSQl
  23. If imgCommand.ExecuteNonQuery() > 0 Then
  24. bResult = True
  25. '關(guān)鍵是這里,需要你手動清除參數(shù)
  26. imgCommand.Parameters.Clear()
  27. End If
  28. Catch ex As Exception
  29. Me.ExceptionMessage = ex
  30. bResult = False
  31. End Try
  32. Return bResult
  33. End Function

以上介紹VB.NET使用OracleTransaction對象。


文章名稱:VB.NET使用OracleTransaction對象深入剖析
網(wǎng)址分享:http://www.5511xx.com/article/cdpshgc.html