Search code examples
c#asp.netms-accesswhere-clausesqldatasource

Using Access yes/no in where clause of a SqlDataSource


I'm trying to populate a dropdownlist control using a SqlDataSource. The data source has a WHERE clause to a yes/no column in access. However when I run the website the DropDownlist control does not populate, even after control.bind in pageload.

Question is:

In creating the SqlDatasource, which source should I use for a column that has yes/no types to resolve this?


Solution

  • If you have an Access database, why not use the System.Data.Odbc or maybe even System.Data.OleDb connections instead of System.Data.Sql.

    Check this possibility, too: When using the System.Data.Sql driver, you may find there are connection specific properties for accessing Microsoft Access databases--so do some reading on this in the MSDN.

    A yes/no column is simply a Boolean column in SQL Server parlance. In Access, you can set yes/no columns to the following values: (yes, true, 1)|(no, false, 0). I believe in T-SQL for SQL Server, Boolean columns must be either: (true, 1)|(false, 0).

    HTH.