I have a grid view that displays data from a SQL Server database during page load. My gridview contains these columns:
AssetType, IssuedOn, ReturnedOn
I have used a query:
SqlCommand cmd = new SqlCommand(
"SELECT * FROM AssetRequest WHERE ReturnedOn IS NULL OR ReturnedOn ='' ORDER BY id DESC",
conn);
which will display data from SQL Server in the gridview when ReturnedOn column doesn't have any data.
The new query has to satisfy these conditions,
- It Should not displays a record when Assetype="Laptop" or "Desktop" and IssuedOn is not empty.
- But if the Assetype="Laptop" or "Desktop" and IssuedOn is empty it should display the record.
- If the Assetype=anything and Returnedon is not empty it should not display that record in gridview.
which will display sql data in gridview when "AssetType" column has data, "IssuedOn" column has data and "ReturnedOn" column doesnt have any data.. What's the filter you need to apply exactly?SELECT * FROM AssetRequest WHERE (ReturnedOn IS NULL OR ReturnedOn ='') AND (IssuedOn IS NOT NULL) AND (AssetType NOT IN ('Laptop', 'Desktop')) ORDER BY id DESC