Accessing .NET Components from SQL Server
2004-02-27 09:23
447 查看
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.
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.
相关文章推荐
- Websharp使用说明(1)
- Websharp使用说明(4)
- Websharp使用说明(2)
- 数据库学习笔记(一)
- [MS SQL] 求一個SQL語句
- access的最大容量
- Oracle PL/SQL语言基础
- VC开发数据库基础之ADO篇 (1)
- VC开发数据库基础之ADO篇 (2)
- 用SQLPLUS调试返回游标集的Oracle存储过程
- 如何让PowerDesigner支持自动生成含SQL Server 2000的表和列注释的角本
- 数据库并发问题详述
- 在.NET中调用DataWindow操作数据库
- 存储过程编写经验和优化措施
- 数据库管理员DBA
- jakarta commons-dbcp
- 数据库连接字在Web.config里的用法
- 初探ERP的数据库框架
- 用设计模式开发通用数据库操作器
- JDBC2.0實現數據分頁