In my ASP.NET MVC application I've been trying to select the data from the table from users that are ACTIVE, which is on a column from the database as true or false, however when I try to do this code, it doesn't show any data:
com.CommandText = "SELECT [NumMec], [NomeCompleto] FROM [CORE_USERS] WHERE [Activo] like 'T%'";
I've tried a different approach, which was controlling the selection by doing a (Data.Activo == "True") in the View. But I don't want this approach, I want to control the data from the database:
@{
if (Model != null)
{
foreach (var Data in Model)
{
if (Data.Activo == "True")
{
<tr>
<td>@Data.NumMec</td>
<td>@Data.Activo</td>
<td>@Data.NomeCompleto</td>
</tr>
}
}
}
}
if you are on sql server and datatype of Activo column is bit, then the correct syntax is :
SELECT [NumMec], [NomeCompleto] FROM [CORE_USERS] WHERE [Activo] = 1
bit = 1 means true