MS SQL Server
  Home arrow MS SQL Server arrow Developing Managed Code and Executing With...
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  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
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? 
MS SQL SERVER

Developing Managed Code and Executing Within Microsoft SQL Server 2000
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 11
    2005-12-15

    Table of Contents:
  • Developing Managed Code and Executing Within Microsoft SQL Server 2000
  • Developing the .NET component
  • How to deploy the .NET component
  • How to call .NET component from within SQL Server 2000
  • Understanding the concept

  • 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


    Developing Managed Code and Executing Within Microsoft SQL Server 2000


    (Page 1 of 5 )

    This article explains how to develop .NET based components and access them using Microsoft SQL Server 2000.
    A downloadable file for this article is available here.

    The sample downloadable solution (zip) is entirely developed using Visual Studio.NET 2003 Enterprise Architect on Windows Server 2003 Standard Edition.  But I am confident that it would work with other versions of Windows (which support .NET 1.1) versions as well.

    Why is it necessary and how can we achieve it?

    In general, if it is related to database related transactions or manipulations, we can easily achieve it using T-SQL (Transact SQL).  By developing our own stored procedure, we can even improve the performance.  But there could be situations where we may need the help of some external routines, which may not be available in SQL Server 2000.  Examples include pinging to another computer, reading a text file, and so on.

    T-SQL, on the other hand, is basically designed only to interact with a database; it is not intended to develop any of the external routines (which are outside the scope of the database).  But, in real scenarios, we may have some of our external routines execute from within the SQL Server 2000 environment.

    The Microsoft SQL Server team thought about these kinds of situations and created support for accessing any COM component from within the SQL Server 2000 environment.  But one should also understand that Microsoft might not (or does not) provide support for any failures in such cases.  If you have guts and if you really test them well before taking it to the production environment, there is no doubt that accessing external routines from within SQL Server 2000 would greatly help programmers.

    Another issue to consider is that Microsoft SQL Server 2000 doesn’t know anything about .NET.  In fact, it doesn’t even know that the CLR, COM+ or other technologies exist within .NET.  It knows how to access external routines only using COM.  There exists no concept like “managed” from SQL Server 2000 point of view.  Then how can we set up our .NET managed code to get accessed from SQL Server 2000?

    As usual, we develop our managed code (.NET code) using a “class library” project, sign it “strongly” and push it into GAC (Global Access Cache).  Since Microsoft SQL Server 2000 doesn’t know anything about GAC, we need to register it as a COM component also (using “RegAsm” Utility).  Once all of the above steps are completed, we can use any of the following “extended stored procedures” in SQL Server 2000, to access the component:

    Sp_OACreate
    Sp_OADestroy
    Sp_OAGetErrorInfo
    Sp_OAGetProperty
    Sp_OAMethod
    Sp_OASetProperty
    Sp_OAStop

    Now, let us move on to implementing the concept.

    More MS SQL Server Articles
    More By Jagadish Chaterjee


       · Databases can be difficult to deal with; I hope you found this article on developing...
     

    MS SQL SERVER ARTICLES

    - Windows Server 2008 as a Workstation OS
    - An Overview of Windows Server 2008 R2
    - LINQ to MySQL, Oracle and PostgreSQL Provide...
    - Completing the Introduction to Transact-SQL
    - A Brief Introduction to Transact-SQL
    - Lookups and Blocking Bad Data
    - Field Validation Rules for Blocking Bad Data
    - Using Masks to Block Bad Data
    - Blocking Bad Data
    - Using @@ROWCOUNT and TABLE Variables for Dat...
    - How to Use Variables, IF and CASE in Databas...
    - Creating Important Aspects of Notification S...
    - Working wth Variables in Database Interactio...
    - Delving Deeper into Notification Services
    - Notification Services





    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek