Friday, March 30, 2012

Parameter problem

hi,
i m using following query in my dataset query string

SELECT OrderNumber, OrderDate, Name AS Client, orderstatus
FROM Orders
Where @.Param

i m sending boolean exp as value for @.param as string like " YEAR(ORderDate) = YEAR(getDate()) "

but is showing following error

An expression of non-boolean type specified in a context where a condition is expected,near '@.param'. (Microsoft Sql Server, Error:4145)

please help me,

thanks
You cannot do that unless you use dynamic Sql in a procedure, passing the string as the parameter which should be avoided.

Jens K. Suessmeyer

http://www.sqlserver2005.de

|||thanks for reply

but can u explain further because i m new to it
|||

You dont need to send the parameter string because whatever you trying to do can be achieved in plain SQL in dataset query itself:

SELECT OrderNumber, OrderDate, Name AS Client, orderstatus
FROM Orders
Where YEAR(OrderDate) = YEAR(GETDATE())

Shyam

|||Wee that depends. if you have the same query everything with carying parameters you can use something like Where YEAR(@.SomeVar) = YEAR(Getdate()), the parameter will automatically mapped to the report if you write such a query in the pane of the query editor in the report designer. but if you want to pass in a whole condition rather than just a parameter you would probably need to pass it to a stored procedure to make it execute in a dynamic SQL statement.

Jens K. Suessmeyer

http://www.sqlserver2005.de

No comments:

Post a Comment