自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

.NET技術(shù)登上主流技術(shù)平臺

開發(fā) 后端
這里介紹.NET技術(shù)是微軟大力推廣的下一代平臺技術(shù),自從.NET技術(shù)架構(gòu)Beta2版本的正式發(fā)布,此項技術(shù)也逐漸走向成熟和穩(wěn)定。

.NET有很多值得學(xué)習(xí)的地方,這里我們主要介紹.NET技術(shù),包括介紹COM/COM+技術(shù)等方面。

.NET技術(shù)是微軟大力推廣的下一代平臺技術(shù),自從.NET技術(shù)架構(gòu)Beta2版本的正式發(fā)布,此項技術(shù)也逐漸走向成熟和穩(wěn)定。按照微軟的平臺系統(tǒng)占有率,我們不難想象得到,在未來的一兩年內(nèi).NET技術(shù)必定會勢如破竹一般的登上主流的技術(shù)平臺,而一個新的技術(shù)平臺得以快速發(fā)展的最重要的前提是:他不會徹底的摒棄以前的技術(shù),這一點對于.NET技術(shù)來說指的就是COM/COM+技術(shù)了。

一般來說,在IT技術(shù)界以及硬件產(chǎn)業(yè),技術(shù)的更新?lián)Q代速度非常得驚人,而慣例是所有的新技術(shù)都會遵循向下兼容的原則,但是.NET技術(shù)不僅僅做到了這一點,.NET甚至實現(xiàn)了相互之間的各自調(diào)用,這一點是非常難能可貴的。也就是說,不但我們可以在.NET組件中調(diào)用COM組件,同時也可以在COM組件中正常的調(diào)用.NET組件。這點帶來的好處是顯而易見的,一方面我們可以保持現(xiàn)有的技術(shù)資源,另一方面,在現(xiàn)有資源中可以利用.NET所帶來的各種新技術(shù)。

一般的數(shù)據(jù)庫事務(wù)控制要求事務(wù)里所做的操作必須在同一個數(shù)據(jù)庫內(nèi),這樣在出現(xiàn)錯誤的時候才能回滾(RllBack)到初始狀態(tài)。這就存在一個問題,在分布式應(yīng)用程序中,我們往往需要同時操作多個數(shù)據(jù)庫,使用數(shù)據(jù)庫本身的事務(wù)處理,很難滿足程序?qū)κ聞?wù)控制的要求。在COM+中,提供了完整的事務(wù)服務(wù),我們可以利用它來完成在分布式應(yīng)用程序中的事務(wù)控制。

具體過程如下

一:用VS.NET生成一個類庫

二:添加對System.EnterpristServices的引用,具體步驟
菜單:(項目-添加引用-在.NET選項卡選擇System.EnterpristServices-確定)

三:構(gòu)建類

  1. using System;  
  2. using System.EnterpriseServices;  
  3. using System.Data.SqlClient;  
  4. using System.Reflection;  
  5. namespace COMPlusSamples  
  6. {  
  7. //表明需要事務(wù)支持[ Transaction(TransactionOption.Required) ]  
  8. //聲明為服務(wù)器應(yīng)用程序,還可以選擇Library,表示為庫應(yīng)用程序  
  9. [assembly: ApplicationActivation(ActivationOption.Server)]  
  10. //描述信息  
  11. [assembly: Description("sample")]  
  12.  
  13. public class TxCfgClass : ServicedComponent  
  14. {  
  15. private static string init1 = "user id=sa;password=;
    initial catalog=pubs;data source=(local)"
    ;  
  16. private static string init2 = "user id=sa;password=;
    initial catalog=NorthWind;data source=(local)"
    ;  
  17. private static string add1 = "insert into authors
    ('au_lname','au_fname') values('test1', 'test2')"
    ;  
  18. private static string add2 = "insert into sample values('test1',22)";  
  19. //the error sql statement  
  20. //there is not table “sample”  
  21. public TxCfgClass() {}  
  22. private void ExecSQL(string init, string sql)  
  23. {  
  24. SqlConnection conn = new SqlConnection(init);  
  25. SqlCommand cmd = conn.CreateCommand();  
  26. cmd.CommandText = sql;  
  27. conn.Open();  
  28. cmd.ExecuteNonQuery();  
  29. conn.Close();  
  30. }  
  31. //添加一條記錄到數(shù)據(jù)庫  
  32. public void Add()  
  33. {  
  34. try  
  35. {  
  36. //在一數(shù)據(jù)庫中插入一條記錄  
  37. ExecSQL(init1, add1);  
  38. Console.WriteLine("the operation in the same database completely");  
  39. //在另外一個數(shù)據(jù)庫中插入兩條記錄  
  40. //這次執(zhí)行的是一個錯誤的SQL語句  
  41. ExecSQL(init2, add2);  
  42. Console.WriteLine("the operation in the other database  
  43. completely");  
  44.  
  45. Console.WriteLine("Record(s) added, press enter...");  
  46. Console.Read();  
  47. }  
  48. catch(Exception e)  
  49. {  
  50. //事務(wù)回滾  
  51. ContextUtil.SetAbort();  
  52. Console.WriteLine("Because there are some errors 
    in the operation ,so transcation abort");  
  53. Console.WriteLine("The error is " + e.Message);  
  54. Console.WriteLine("abort successfully");  
  55. Console.Read();  
  56. }  
  57. }  
  58. }  

【編輯推薦】

  1. .NET VS Java平臺之爭的理性思考
  2. .NET C# DES入門淺析
  3. .NET寫入文本文件的操作淺析
  4. .NET自定義控件應(yīng)該如何實現(xiàn)?
  5. 淺析.NET 4.0和Visual Studio 2010多定向支持
責(zé)任編輯:佚名 來源: chinaitlab
相關(guān)推薦

2021-02-22 10:32:53

大數(shù)據(jù)大數(shù)據(jù)平臺大數(shù)據(jù)技術(shù)棧

2009-10-16 16:52:16

電纜布線技術(shù)

2009-09-01 16:08:06

主流寬帶技術(shù)光纖

2010-03-18 14:54:46

主流無線技術(shù)

2009-10-29 08:49:28

無線接入技術(shù)

2021-01-18 18:15:00

GitHub 技術(shù)開發(fā)

2011-09-02 09:42:04

.NET平臺

2014-07-28 15:35:27

混搭NET技術(shù)

2023-01-13 11:27:13

戰(zhàn)略平臺Forrester

2016-03-24 09:43:57

無線通信技術(shù)無線技術(shù)

2010-08-09 10:54:30

RIAFlex

2009-07-29 15:38:01

2009-10-29 09:25:18

寬帶接入技術(shù)

2018-03-06 14:44:59

2009-12-29 15:44:11

ADO.NET檢索技術(shù)

2021-02-17 10:55:32

XRVRAR

2015-07-23 14:28:04

.NET技術(shù)大系

2015-10-28 09:56:43

物聯(lián)網(wǎng)減肥

2016-03-14 13:14:34

物聯(lián)網(wǎng)物聯(lián)網(wǎng)技術(shù)

2010-01-05 16:38:05

Ubuntu軟件
點贊
收藏

51CTO技術(shù)棧公眾號