Accessing .NET Components from SQL Server

來源:互聯網
上載者:User

From: http://www.sqljunkies.com/Tutorial/C5A500EB-B8BE-42C0-B23B-258A342CAAAB.scuk

In the articles titled Using COM Objects in SQL Server and Extending SQL Server with COM Objects, we saw the
basics of how to access and use COM objects from SQL Server. With the advent of .NET, it is natural for us to see if SQL Server can call into .NET objects. Unfortunately, you cannot, as described in the following article. But don't lose heart, you can access .NET objects in an indirect way using an intermediate COM wrapper. This COM wrapper can call into the .NET code using interop. In this example, we will see how to exploit this feature.

The steps for accessing .NET objects from SQL Server is quite straightforward. The following are the steps:

  • Create the .NET class by defining an interface and having a .NET class implement the interface.
  • Generate a strong name for the assembly using the SN tool and add the relevant assembly attributes.
  • Compile the assembly and use the REGASM tool to generate the type library for the assembly and register the same.
  • Run the GACUTIL program to register this assembly in the GAC.
  • Write the Visual Basic 6 DLL wrapper over this .NET assembly by adding the appropriate references.
  • Compile this DLL and place it in some folder.
  • Write the SQL Server calls for this VB 6 DLL. This in turn invokes the .NET DLL which returns the result.
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.