Accessing .NET Components from SQL Server

文章探讨了SQL Server能否调用.NET对象,指出不能直接调用,但可通过中间COM包装器间接访问。还详细介绍了从SQL Server访问.NET对象的步骤,包括创建.NET类、生成程序集强名称、编译注册程序集、编写VB 6 DLL包装器等。

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.

转载于:https://www.cnblogs.com/coollzh/archive/2004/02/27/1719.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值