I need to execute the query according to the Businessunit values which is to be passed in runtime. If the businessunit is null the AND condition should not get executed and if it is not null i have to take the businessunit which is passed.
// SQL Query
SELECT nvrEmpCode, nvrEmpName
FROM tblHRIMS_EmployeeDetail
WHERE (intCategoryID NOT IN (0, 1)) AND (nvrResigned = 'No')
AND nvrBusinessunit=
All these must be done in a SQLDatasource and not as a StoredProcedure. How to achieve this?
Your WHERE
condition should be like this:
WHERE (intCategoryID NOT IN (0, 1)) AND (nvrResigned = 'No')
AND (@businessunit IS NULL OR nvrBusinessunit=@businessunit)