Missing parameter for data adapter select

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I am using below in my dataadapter SELECT statement;

SELECT <field list>
FROM Clients
WHERE (Status = ?)
ORDER BY ID

What if I need all clients regardless of status, is there a way to modify
the above statement to include this situation or is a second query needed
for that?

Thanks

Regards
 
John,

I never tried this with an inline Sql procedure , but you can try

Where(status is null or status = ?)

And please let us know if this works. I assume you are using OleDB because
you use the ?

In a SQL stored procedure you simple declare a parameter as

@Status bool = null

and then

Where (@Status is null or Status = @Status)

Cor
 
Hi Cor

Doesn't work.

Thanks

Regards

Cor Ligthert said:
John,

I never tried this with an inline Sql procedure , but you can try

Where(status is null or status = ?)

And please let us know if this works. I assume you are using OleDB because
you use the ?

In a SQL stored procedure you simple declare a parameter as

@Status bool = null

and then

Where (@Status is null or Status = @Status)

Cor
 
Hi

I am using below in my dataadapter SELECT statement;

SELECT <field list>
FROM Clients
WHERE (Status = ?)
ORDER BY ID

What if I need all clients regardless of status, is there a way to modify
the above statement to include this situation or is a second query needed
for that?

Thanks

Regards

You could try:
SELECT ... FROM ... WHERE ? IS NULL OR Status = ? ORDER BY ...

and pass in NULL for the parameter to get all records. I assume you
are using OLEDB, and I don't know it if allows a parameter to be
tested like that.
 
Back
Top