. Net distributed transaction example

Source: Internet
Author: User
Using System; // reference the System namespace
Using System. Data. OleDb; // reference the ADO.net namespace
Using System. Data; // reference the Data space
Using System. Runtime. InteropServices; // to call the GUID
Using System. EnterpriseServices; // reference the COM + namespace
Using System. Runtime. CompilerServices; // compile the server at Runtime
Using System. Reflection; // use some global attributes to obtain the strong name attribute.
Using System. Data. SqlClient;
[Assembly: ApplicationName ("COMLibrary")]
// Strong name file name and file attributes. Generated with sn.exe, using 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 =" yanlixinscgl "; p" +
"Ersist security info = True; initial catalog = scgl; password = scgl ";
//
MyConnection = new SqlConnection (connection );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.