473,385 Members | 1,588 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

CLR for sql server 2005

aas4mis
97
I know this is C#, but thought the SQL community would know better. I'm trying to get a CLR compiled to handle a Double.TryParse() via TSQL and the code won't compile.

I'm no C# guru, found this code on the web when looking for a way to try_parse in earlier versions of sql (2005).

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Data.SqlTypes;
  6. using Microsoft.SqlServer.Server;
  7.  
  8. namespace ClassLibrary1
  9. {
  10.     public class Class1
  11.     {
  12.         [SqlFunction]
  13.         public static SqlDouble TryParseDouble(SqlString str) 
  14.         { 
  15.                 Double d; 
  16.                 bool success = Double.TryParse(str, out d)
  17.                 if (!success)     
  18.                        return SqlDouble.Null; 
  19.                 return new SqlDouble(d); 
  20.         } 
  21.     }
  22. }
  23.  
The underlined is where my issue is. Here is the error.

Expand|Select|Wrap|Line Numbers
  1. Error    1    The best overloaded method match for 'double.TryParse(string, out double)' has some invalid arguments    c:\xxxxx\Class1.cs    16    32    ClassLibrary1
  2. Error    2    Argument 1: cannot convert from 'System.Data.SqlTypes.SqlString' to 'string'    c:\xxxxx\Class1.cs    16    48    ClassLibrary1
  3.  
Any help on the matter would be appreciated, i'm ready for an easier way to convert varchar to decimal(18,8) and not break on errors to be expected.

Thanks!
Sep 13 '11 #1
2 1711
aas4mis
97
Nevermind.. :) Looks like the 'str' inside of the Double.TryParse() needed to be 'str.Value'. I'll load this into sql and post back if it works.

Thanks!

(you know, it's bad enough to talk to ones self, but to answer ones self??).. Programmers
Sep 13 '11 #2
Rabbit
12,516 Expert Mod 8TB
Why not use the ISNUMERIC() function that's available in T-SQL?
Sep 13 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Larry Bertolini | last post by:
I was browsing Microsoft's SQL Server site, looking for some details about SQL Server 2005. Didn't find what I was looking for... I'm thinking about moving an existing SQL Server 2000 workload...
1
by: Peter | last post by:
I've purchased VS.NET 2005 Standard and have tried to install SQL Server 2005 Express, but get the following error in the error log. Please could someone help me.... Microsoft SQL Server 2005...
4
by: Greg P | last post by:
I know this is a long post, please bear with me. I have been working on this all weekend to no avail although I have done a good amount of research (see most pertinent links that I've looked at...
7
by: Greg P | last post by:
I know this is a long post, please bear with me. I have been working on this all weekend to no avail although I have done a good amount of research (see most pertinent links that I've looked at...
2
by: nitin | last post by:
HI all Gurus i am struck up in sql 2005.I am new to sql 2005.I have my server installed on one machine.Now what do i download so that i am able to register it. Now i want to connect to that...
10
by: MVChauhan | last post by:
Hi We are planning to move over to SQL Server 2005 in near future. At the moment Website is on a seperate server then the Database. OS for both the server is Window 2003 and currently our data...
4
by: jmnaste | last post by:
Hi, I tried to migrate data of an Access 2003 application (.mdb) to SQL Server 2005 Express. Using the Wizard and choosing 'create a new database', I receive (a French message saying roughly)...
10
by: Henrik Dahl | last post by:
Hello! I have an xml schema which has a date typed attribute. I have used xsd.exe to create a class library for XmlSerializer. The result of XmlSerializer.Serialize(...) should be passed as the...
3
by: Lee T. Hawkins | last post by:
I am having a number of problems over the last two full days trying to get an ASP.NET 2.0 application to connect to a SQL Server 2005 database... First off, I built this application w/ Visual...
0
Dököll
by: Dököll | last post by:
ASP.NET and SQL Server 2005 Database interaction includes: Language: ASP.NET Connectivity: SQL Server 2005 Foreword: This database connectivity is nothing of genius, it is a simple...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.