Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

sql server 2008 register dll

Posted on 2010-08-23
5
Medium Priority
?
571 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 60

Accepted Solution

by:
Kevin Cross earned 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

886 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