Hi guys,
I am using VS 2005 with SQL 2005 and latest version of LLBLGen.
I am trying to return the minutes that a request has taken so it is a DateDiff between the datetime requested and the current date of course. I am using a dynamic list to get the data. Following line:
fields[7].ExpressionToApply = new DbFunctionCall("DATEDIFF", new object[] { "mi", RequestFields.DateTimeRequested, new DbFunctionCall("GETDATE", null) });
throws an error saying:
System.Data.SqlClient.SqlException: Invalid parameter 1 specified for datediff.
Incorrect syntax near the keyword 'AS'.
Incorrect syntax near 'preLink'.
When i comment out the expression the query runs with out any errors.
THis is the query that llblgen generates with the expression:
exec sp_executesql N'SELECT [preLink].[dbo].[Request].[RequestId], [preLink].[dbo].[Request].[RequestNumber], [preLink].[dbo].[Person].[LastName],
[preLink].[dbo].[Person].[Initials], [preLink].[dbo].[Person].[FirstName], [preLink].[dbo].[Person].[IDNumber] AS [Idnumber], [preLink].[dbo].[Request].[DateTimeRequested],
[preLink].[dbo].[Site].[Name] AS [SiteName], DATEDIFF(@LOcdf1b7c31, [preLink].[dbo].[Request].[DateTimeRequested], GETDATE()) AS [TurnAroundTime], (SELECT TOP 1
[preLink].[dbo].[Station].[Name] FROM ( [preLink].[dbo].[Station] INNER JOIN [preLink].[dbo].[Site_Station] ON
[preLink].[dbo].[Station].[StationId]=[preLink].[dbo].[Site_Station].[StationId]) WHERE ( [preLink].[dbo].[Site_Station].[SiteId] = [preLink].[dbo].[Site].[SiteId])) AS
[PatientLocation] FROM (((( [preLink].[dbo].[Request] INNER JOIN [preLink].[dbo].[RequestMonitor] ON
[preLink].[dbo].[Request].[RequestId]=[preLink].[dbo].[RequestMonitor].[RequestId]) INNER JOIN [preLink].[dbo].[Patient] ON
[preLink].[dbo].[Patient].[PatientId]=[preLink].[dbo].[Request].[PatientId]) INNER JOIN [preLink].[dbo].[Person] ON
[preLink].[dbo].[Person].[PersonId]=[preLink].[dbo].[Patient].[PatientId]) INNER JOIN [preLink].[dbo].[Site] ON
[preLink].[dbo].[Site].[SiteId]=[preLink].[dbo].[Request].[PerformSiteId]) WHERE ( ( [preLink].[dbo].[RequestMonitor].[InstrumentId] IN (@InstrumentId2, @InstrumentId3,
@InstrumentId4))) ORDER BY [preLink].[dbo].[Request].[DateTimeRequested] DESC',N'@LOcdf1b7c31 nvarchar(2),@InstrumentId2 uniqueidentifier,@InstrumentId3
uniqueidentifier,@InstrumentId4
uniqueidentifier',@LOcdf1b7c31=N'mi',@InstrumentId2='1DE160B0-DD6F-DB11-BA37-00188B18D3A4', @InstrumentId3='74355BB3-D76F-DB11-BA37-00188B18D3A4', @InstrumentId4='D6064267-D76F-DB11-BA37-00188B18D3A4'
Thanks very much,
Russell