Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


failed to convert parameter value from a string to a double


failed to convert parameter value from a string to a double

Author
Message
pearcea
pearcea
Grasshopper
Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)

Group: General Forum Members
Points: 12 Visits: 24
I have a stored procedure on a SQL 2005 DB that retrieves data from a mysql DB on another server (none of this was set up by myself)

The sp is as follows:

USE [InSightLiveData]
GO
/****** Object: StoredProcedure [dbo].[GetHoursWorkedBetweenDates] Script Date: 03/05/2014 15:40:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--ALTER FUNCTION [dbo].[fn_TestFunc] ( @Adviser int, @InitialDate datetime, @FinalDate datetime ) RETURNS float
ALTER procedure [dbo].[GetHoursWorkedBetweenDates] (
@Adviser varchar(10),
@InitialDate varchar(10),
@FinalDate varchar(10),
@hours float out )
AS
BEGIN
--declare @hours float
   declare @sql as nvarchar(1000)
   declare @linkedserversql as nvarchar(1000)
   declare @param_definition as nvarchar(1000)
-- set @sql = 'call flexi.GetHoursWorkedBetweenDates(''62843'',''2014-01-27'',''2014-02-23'');';
-- select @hours = total_time_decimal from openquery(fleximysql, @sql );
--select @hours = total_time_decimal from openquery(fleximysql, 'call flexi.GetHoursWorkedBetweenDates(''62843'',''+ @InitialDate +'',''2014-02-23'');');

-- the one below works for literal values only
--select @hours = total_time_decimal from openquery(fleximysql, 'call flexi.GetHoursWorkedBetweenDates(''62843'',''2014-01-27'',''2014-02-23'');');
--exec('call flexi.GetHoursWorkedBetweenDates(''62843'',''2014-01-27'',''2014-02-23'');') at fleximysql;

--exec('select ? = count(*) from flexi.work_time', @hours output) at fleximysql;
--exec('select ? = max(time_worked) from flexi.work_time', @hours output) at fleximysql;
   set @linkedserversql = 'call flexi.GetHoursWorkedBetweenDates('+@adviser+','''+@initialdate+''','''+ @finaldate +''')';
   set @sql = 'select @hoursout = total_time_decimal from openquery(fleximysql, ''' + Replace(@linkedserversql,'''','''''') + ''')'
   set @param_definition = '@hoursout float out'; --, @adviserin varchar(12)' --, @InitialDate datetime, @FinalDate datetime';
   execute sp_executesql @sql, @param_definition, @hoursout=@hours out; --, @adviserin='2014-01-27'; --, @InitialDate, @FinalDate;
END

If I run exec('call flexi.GetHoursWorkedBetweenDates(''62843'',''2014-01-27'',''2014-02-23'');') at fleximysql; on the SQL server iot works fine but when I set up a new SSRS report calling the stored procedure I get the error:

failed to convert parameter value from a string to a double

When I run the stored procedure in visual studio I have tried all the different ways of entering the values for the dates I can think of but I still get the error.

I'm not sure why the date parameters in the sp are set as varchars, I can only wonder if it's to be compatible with the mysql DB.

Thanks
Annie
Jack Corbett
  Jack Corbett
SSChampion
SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)

Group: General Forum Members
Points: 11014 Visits: 14858
I'm not really familiar with accessing MySQL from a linked server, but I'd suggest converting the @advisor to a compatible data type when passing it to sp_ExecuteSql



Jack Corbett

Applications Developer

Don't let the good be the enemy of the best. -- Paul Fleming
At best you can say that one job may be more secure than another, but total job security is an illusion. -- Rod at work

Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
perskin27
perskin27
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 1
The use of flip-flops is believed to cause many pains and injuries, including ankle sprains and broken bones. Some individuals who walk for long periods report pain in the feet, ankles, and lower legs. But it is also not very comfortable and convenient if your foot is enclosed all the time with shoes. Just see the result that heels bring to girls and ladies.

_______________________________________________

denim jeans
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search