Solved

sql server 2008 register dll

Posted on 2010-08-23
5
535 Views
Last Modified: 2012-06-27
hi experts, i have this code
namespace ConvertNumberToText
{
    public class Utilities
    {
        public string GetStringFromNumber(double value)
        {
            Dictionary<double, string> map = new Dictionary<double, string>()
    {
        {  0F, "CERO" },
        {  1F, "UNO" },
.....

i am trying to register the dll in database

sp_configure 'clr enabled', 1
reconfigure
go

create assembly [Amag.ConvertNumberToText]
from 'C:\Certifica\ConvertNumberToText.dll'

create function ConvertirNumerosALetra (@nota decimal(2,2)) returns nvarchar(500)
external name [Amag.ConvertNumberToText].[ConvertNumberToText.Utilities].GetStringFromNumber;
 
I need to register this dll in the database, but I get the following error:Mens 6573, Level 16, State 1, Procedure ConvertirNumerosALetra, Line 1Method, property or the 'GetStringFromNumber' class 'ConvertNumberToText.Utilities' from assembly 'ConvertNumberToText' is not static.
0
Comment
Question by:enrique_aeo
  • 3
5 Comments
 
LVL 3

Expert Comment

by:shawnmstout
ID: 33506048
i believe this tutorial is what your searching for

http://msdn.microsoft.com/en-us/library/ms164653.aspx
0
 

Author Comment

by:enrique_aeo
ID: 33506067
if I read that article but did not resolve my problem, I would like assistance with the code that I copied
0
 

Author Comment

by:enrique_aeo
ID: 33506340
i attached my code
Nuevo-documento-de-texto.txt
0
 
LVL 59

Accepted Solution

by:
Kevin Cross earned 500 total points
ID: 33507645
As the error message says you are missing the "static" modifier on your message. Remember that you are building a set of utility functions which are typically public static.

i.e., you want to call this as ConvertNumberToText.Utilities.GetStringFromNumber(0.0)

So very simple fix to your code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConvertNumberToText
{
   public class Utilities
   {
      
      public static string GetStringFromNumber(double value)
      {
         Dictionary<double, string> map = new Dictionary<double, string>()
   {
      {  0F, "CERO" },
      {  1F, "UNO" },
      {  2F, "DOS" },
      {  3F, "TRES" },
      {  4F, "CUATRO" },
      {  5F, "CINCO" },
      {  6F, "SEIS" },
      {  7F, "SIETE" },
      {  8F, "OCHO" },
      {  9F, "NUEVE" },
      { 10F, "DIEZ" },
      { 11F, "ONCE" },
      { 12F, "DOCE" },
      { 13F, "TRECE" },
      { 14F, "CATORCE" },
      { 15F, "QUINCE" },
      { 16F, "DIECISEIS" },
      { 17F, "DIECISIETE" },
      { 18F, "DIECIOCHO" },
      { 19F, "DIECINUEVE" },
      { 20F, "VEINTE" },
      { 30F, "TREINTA" },
      { 40F, "CUARENTA" },
      { 50F, "CINCUENTA" },
      { 60F, "SESENTA" },
      { 70F, "SETENTA" },
      { 80F, "OCHENTA" },
      { 90F, "NOVENTA" },
   };

         double whole = Math.Truncate(value);
         double fraction = Math.Round((value - whole), 2);
         StringBuilder result = new StringBuilder();

         if (!map.Keys.Contains(whole))
         {
            double ones = whole % 10;
            double tens = Math.Truncate((whole / 10) % 10) * 10;

            result.Append(map[tens] + " y " + map[ones]);
         }
         else
         {
            result.Append(map[whole]);
         }

         if (fraction != 0D)
         {
            result.Append(" PUNTO ");

            fraction = Math.Round(fraction * 100);

            if (!map.Keys.Contains(fraction))
            {
               double hundredths = fraction % 10;
               double tenths = Math.Truncate((fraction / 10) % 10) * 10;

               result.Append(map[tenths] + " y " + map[hundredths]);
            }
            else
            {
               if (fraction < 10D)
               {
                  result.Append(map[0] + " " + map[fraction]);
               }
               else
               {
                  result.Append(map[fraction]);
               }
            }
         }

         return result.ToString();
      }
   }
}

Open in new window

0
 

Author Comment

by:enrique_aeo
ID: 33512036
OK MY FRIEND,
that problem is already solved. Thanks
Now I have this otherError in CREATE FUNCTION for "ConvertirNumerosALetra" because the types T-SQL and CLR parameter "@ note" do not match.

create function ConvertirNumerosALetra (@nota decimal(2,2)) returns nvarchar(500)
external name [Amag.ConvertNumberToText].[ConvertNumberToText.Utilities].GetStringFromNumber;
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
MS SQL store procedure to calculate and return result 6 35
backups - Strategies 1 13
Sql query for filter 12 23
SqlAdvisor 2016 3 11
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now