Need help with a query

  • Thread starter Thread starter Don
  • Start date Start date
D

Don

I'm having trouble getting a particular query to work with ADO.NET. I want
to create a query where a returned field contains a certain string depending
on the which of several boolean fields in the database is true. I need a
function that will work in both Access 2000 and SQL Server, but I can't get
anything to work properly. I used to be able to do this with the Switch()
function with DAO and Access97. Does anyone know of a way to do this now
with both Access 2000 and SQL Server?

- Don
 
You can use the Case Statement in SQL Server:

CASE
WHEN Boolean_expression THEN result_expression
[...n]
[
ELSE else_result_expression
]
END



I'm not an Access expert, so to the best of my knowledge Access doesn't
support Case Statements and T-SQL Doesn't support IIF which is a scaled down
Case. Could you write them both and just call the different ones depending
on which DB you are using? Perhaps a compiler directive could signal the
different provider and you could branch from there?



HTH,



Bill
 
Back
Top