Well, the SQL is quite simple, I just use a pattern solution that the oledb seems to find problems solving the SQL. The database I am working with is SQL Server 2000 which is running on a Windows 2000 server local.

select top 1 * from user
(user_ID = :id or :All = 1) and
(dep_ID = :dep or :AllDep = 1) and
(card_num = :card or :AllCards = 1)

It might appear a little strange but this SQL fits perfectly to my code on many situations, and as the system also work with other database I wouldn´t like to change it. The same syntax works fine with postgreSQL and oracle.

I am using dbexpress technology. The SQL is in a SQLQuery which has a DataSetProvider connected to, which also have a ClientDataSet connected to. This last one is the one I use to open the query an pass the parameters.

If someone can give me any help I'll eternely greatfull.