国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

.net分布式事務例子

2024-07-10 12:59:04
字體:
來源:轉載
供稿:網友
using system;//引用系統命名空間
using system.data.oledb;//引用ado.net命名空間
using system.data;//引用數據空間
using system.runtime.interopservices;//為了調用guid
using system.enterpriseservices;//引用com+名命空間
using system.runtime.compilerservices;//運行時編譯服務器
using system.reflection;//用些全局屬性取得強名屬性
using system.data.sqlclient;
[assembly: applicationname("comlibrary")]
//強名文件名和文件屬性。用sn.exe生成,用法 sn -k clsstock.snk
//[assembly: assemblykeyfileattribute("clsstock.snk")]
//[assembly: assemblykeyname("clsstock.snk")]
[assembly: assemblykeyfileattribute("..//..//clsstock.snk")]
[assembly: assemblykeyname("..//..//clsstock.snk")]
namespace comlibrary
{
[transaction(transactionoption.required)]
public class dboperation:servicedcomponent
{

private sqlconnection myconnection;
private sqlcommand mycommand;

/// <summary>
/// connect database
/// </summary>
/// <param name=”connection”>database config infomation
/// formatting : datasource=..;user id=..;password=...
/// </param>
/// <returns></returns>
public void connect()
{
string connection="workstation id=yanlixin;packet size=4096;user id=sa;data source=/"yanlixin//scgl/";p" +
"ersist security info=true;initial catalog=scgl;password=scgl";
//
myconnection = new sqlconnection( connection );
myconnection.open();

mycommand = new sqlcommand();
mycommand.connection = myconnection;

return;
}

/// <summary>
/// execute one insert statement and insert one record into the table
/// </summary>
/// <param name=”connection”>database config infomation
/// formatting : datasource=..;user id=..;password=...
/// </param>
/// <returns></returns>

public int commandexcute(string commandstring)
{

int returnvalue = 0;

mycommand.commandtext = commandstring;
returnvalue = mycommand.executenonquery();

return returnvalue;

}

/// <summary>
/// commit the com+ transaction
/// </summary>

public void commit()
{

contextutil.setcomplete();

if(myconnection!=null)
myconnection.close();

}

/// <summary>
/// roolback the com+ transaction
/// </summary>

public void abort()
{

contextutil.setabort();

if(myconnection!=null)
myconnection.close();

}

}
}



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 乌海市| 东莞市| 临洮县| 晋城| 定远县| 满城县| 广昌县| 交城县| 南丹县| 翁牛特旗| 西峡县| 正定县| 南投市| 永平县| 沁水县| 张掖市| 江口县| 靖江市| 离岛区| 通山县| 衡水市| 宾川县| 焉耆| 安溪县| 慈溪市| 古蔺县| 环江| 鄂伦春自治旗| 广东省| 宣汉县| 孝昌县| 微山县| 萍乡市| 罗平县| 淄博市| 郯城县| 海晏县| 砀山县| 武平县| 贵溪市| 贵溪市|