国产探花免费观看_亚洲丰满少妇自慰呻吟_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();

}

}
}



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 东兰县| 阳原县| 即墨市| 房产| 晋江市| 邮箱| 长兴县| 桂平市| 监利县| 驻马店市| 同德县| 石屏县| 大埔县| 平阴县| 洛南县| 通海县| 于都县| 西青区| 华坪县| 安丘市| 沙湾县| 佛学| 莱西市| 醴陵市| 剑川县| 澎湖县| 清水河县| 尼勒克县| 胶南市| 柳河县| 池州市| 公安县| 吕梁市| 沈阳市| 承德县| 陆川县| 石泉县| 和硕县| 东方市| 高邑县| 肥东县|