Home c# Connecting C # Library to MS SQL Database Server

Connecting C # Library to MS SQL Database Server

Author

Date

Category

I want to create in the MSSQL CLR database function.

For this, I created the C # library in Visual Studio. It has the following class:

namespace classlibrary
{
  Public Class Multiplyclass
  {
    Public Static Int MultiPly (int x1, int x2)
    {
      Return x1 * x2;
    }
  }
}

In the database, I prescribed the following commands:

use admissions_board;
Exec sp_configure 'clr enabled', 1;
Exec Sp_configure 'Clr Strict Security', 0;
Reconfigure.
Go.
Create Assembly Demoassembly
From 'C: \ Users \ RAFFL \ Source \ Repos \ ProgramDB \ ClassLibrary \ Bin \ debug \ classlibrary.dll'
with permission_set = safe;
Go.

It seems to be all connected, but when I want to create a function in the database:

create function fn_multiply (@ num1 int, @ num2 int)
Returns int
AS external name demoassembly.multiplyclass.multiply;
Go.

Output error:

Message: 6505, Level: 16, Condition: 2, Procedure: FN_Multiply, Row: 1 [Starting Package Row: 9]
Failed to detect the "MultiplyClass" type in the "ClassLibrary" assembly.

I do not know why it can not find this class. I tried to do the same class Static , the same error, can not find this class.


Answer 1, Authority 100%

Add neurpeca to the address in the assembly

create function fn_multiply (@ num1 int, @ num2 int)
Returns int
AS EXTERNAL NAME DEMOASSEMBLY. [ClassLibrary.multiPlyClass] .multiPly;

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions