SQL - query for True or False records

0

I'm putting together a simple page that shows records marked as blocked by admin. The field is user-block and the options are FALSE or TRUE.

I imagined that Query would be:

"Select * from Usuarios WHERE user-block = "&TRUE&" order by NOME asc"

But this select returns missing parameter error

Can anyone explain what's wrong with the statement?

    
asked by anonymous 27.08.2017 / 02:11

2 answers

0

Problem solved. Just filter the records after you select them:

sSQL = "Select * from Usuarios order by nome asc"       

set RStemp = createobject("adodb.recordset")
set RStemp.activeconnection = usersDB

regs = 10
pag = 1

RStemp.cursortype = 3
RStemp.pagesize = regs
RStemp.open sSQL
TotalInscritos = RStemp.RecordCount
RStemp.filter = "user-block = TRUE"

I hope the solution is useful for others

    
27.08.2017 / 03:54
0

The correct one in your would be:

Select * from Usuarios WHERE [user-block]=true order by NOME asc

simply because of the dash ( - ) you have to put brackets ( [ and ] ), and it would not be very cool to do so, with underscore , that is, dash underneath example user_block , but that would solve your doubts.

Complete Code

<%

    dim connection
    dim result

    set connection = Server.CreateObject("ADODB.Connection")
    set result = Server.CreateObject("ADODB.recordset")

    connection.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Temp\adm.mdb"


    result.Open "SELECT * FROM Usuarios WHERE [user-block]=true", connection



    Do While Not result.EOF
        Response.Write(result.Fields("Id") & " - ")
        Response.Write(result.Fields("Nome") & " - ")
        Response.Write(result.Fields("user-block"))
        Response.Write("<br />")

        result.MoveNext
    Loop

    connection.Close
    set connection = Nothing
%>

27.08.2017 / 04:09