Hey I have the following Stored ProcedureCREATE PROCEDURE spGetOrderCount( @search varchar(1000) = default)ASSET NOCOUNT ON/* Setup search string */IF (@search <> '')BEGIN SET @search = 'WHERE' + @searchEND/* Create a temporary table */CREATE TABLE #TempTable( row int IDENTITY, totalCount int)/* Insert the search results into query */EXEC( 'INSERT INTO #TempTable([totalCount])' + 'SELECT COUNT(*) AS totalCount ' + 'FROM tblOrders' + @search )/* Extract the wanted records from the temporary table */SELECT [totalCount], RecordsLeft = ( SELECT COUNT(*) FROM #TempTable TI ) FROM #TempTableSET NOCOUNT OFFRETURN;GO
And then the following function which specifies the where clause of the statementfunction getOrderCount(strDate, strStatusList)getOrderCount = 0dim objRS, objSP, strWhereClauseif isDate(strDate) and len(strStatusList) > 0 then'# Filter on order status '# Filter on date clausestrWhereClause = "(tblOrders.orderDate >= " & sqlServerDate(strDate) & ")" '# GET order countSet objSP = SQLGetProcedure("spGetOrderCount")SQLSetProcedureParam objSP, "search", strWhereClauseSet objRS = SQLExecuteProcedure(objSP) if not objRS.eof thengetOrderCount = objRS("totalCount")end if '# Free resourcesdeleteRecordset(objRS)deleteObject(objSP) end if end function When I do this together I get the following error on my ASP Page Microsoft OLE DB Provider for SQL Server error '80040e14' Line 1: Incorrect syntax near '.'. /sigma_eircommobdispatch/server/database.asp, line 235 And the print out of the resulting string from the function is(tblOrders.orderDate >= CONVERT(DATETIME, '2007-7-13', 102))
If i remove the Where clause the statement works fine..Any ideas