.NET
  Home arrow .NET arrow Page 4 - Dealing with .NET Enterprise Services: .NE...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
.NET

Dealing with .NET Enterprise Services: .NET Remoting, Web Services and Service Components
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 13
    2006-02-08

    Table of Contents:
  • Dealing with .NET Enterprise Services: .NET Remoting, Web Services and Service Components
  • Working with the Remoting Client and Remoting Object
  • Working with a basic COM application
  • Working with a database-based COM application
  • Working with Web Services
  • Working with database based Web Services

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Dealing with .NET Enterprise Services: .NET Remoting, Web Services and Service Components - Working with a database-based COM application


    (Page 4 of 6 )

    Let us go through the following program.

    <ClassInterface(ClassInterfaceType.AutoDispatch), Transaction
    (TransactionOption.Supported), ConstructionEnabled([Default]:="Data Source=.;Initial Catalog=Northwind;User
    id=sa"), JustInTimeActivation()> _
    Public Class DBTest
        Inherits ServicedComponent
     
        Dim m_ConnectionString As String
     
        Protected Overrides Sub Construct(ByVal constructString As String)
            ' Called after constructor
            m_ConnectionString = constructString
        End Sub
     
        Public ReadOnly Property ConnectionString()
            Get
                Return m_ConnectionString
            End Get
        End Property
     
        <AutoComplete()> _
        Public Sub ExecuteDML(ByVal strSQL As String)
            Dim cn As New SqlConnection(m_ConnectionString)
            cn.Open()
            Dim cmd As New SqlCommand(strSQL, cn)
            cmd.ExecuteNonQuery()
            cmd.Dispose()
            cn.Close()
        End Sub
    End Class

    You can provide a connection string within your COM+ application (which can be modified later, even at run time, using a Component Services snap-in).  And to retrieve the same connection string you use the following code fragment:

        Protected Overrides Sub Construct(ByVal constructString As
    String)
            ' Called after constructor
            m_ConnectionString = constructString
        End Sub

    And you can expose the same connection string using the following code:

        Public ReadOnly Property ConnectionString()
            Get
                Return m_ConnectionString
            End Get
        End Property

    The “ExecuteDML” method is the most important method of the above COM+ application.  It has an attribute, “<AutoComplete>”, which says that the transaction has to commit after successful execution (or roll back if any error arises).

    The client program to call the above database-based COM+ would be as follows:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
    As System.EventArgs) Handles Button1.Click
     
            Dim obj As New COMPlusEx2Srv.DBTest
            MessageBox.Show(obj.ConnectionString)
            obj.ExecuteDML(Me.txtQuery.Text)
            MessageBox.Show("Updated succesfully")
        End Sub

    The above code just creates an object of the COM+ application and accesses its properties (“ConnectionString”) and methods (“ExecuteDML”).

    More .NET Articles
    More By Jagadish Chaterjee


       · Hai, the article guides you in working with .NET enterprise distributed computing. ...
     

    .NET ARTICLES

    - Using CrystalReportViewer to Display Crystal...
    - Creating Summary .Net Crystal Reports
    - More on Commands, Input and the WPF
    - Grouping and Aggregating When Querying LINQ ...
    - Commands, Input and the WPF
    - Keyboard and Ink Input with WPF
    - Mouse Input and the WPF
    - Input with Windows Presentation Foundation
    - Introducing LINQ with XML and Databases
    - An Introduction to LINQ
    - Querying LINQ to SQL: Basics
    - Completing a Simple Storefront with LINQ
    - Knowing Your Environment: the System.Environ...
    - Creating the Home Page for a Simple Storefro...
    - LINQ Quickly with Language Integrated Queries





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT