Retrieve all records when SelectCommand.Parameters[].Value is null
hi every body
I have a SelectCommand and i use code below to set it value
Code:
DataAdapter.SelectCommand.Parameters["@code"].Value = str_code;
and i defin the parameters with code:
Code:
DataAdapter.SelectCommand.CommandText = "SELECT * FROM Table where (code= @code)";
DataAdapter.SelectCommand.Parameters.Add("@code", SqlDbType.NVarChar, 50, "code");
now i want when str_code is null SelectCommand retrieve all records in database but i dont want to use condition statments becaus i have many parameters and then i have to write about 100 if-then
i need a T-SQL for doing it
thank you all.
Re: Retrieve all records when SelectCommand.Parameters[].Value is null
You can pass the parameter to a stored procedure and check in there if it is null or 0 then do the Select all, and use a reader to get the results?