Estou com o seguinte problema..... tenho a pagina adm que cadastro o classificado.... neste cadastro vc tem a opção para escolher entre 3 opções no checkbox... se vc escolhe as tres no banco de dados ele cadastra item1,item2,item3 ......... porem se faço um "SELECT * FROM CLASSIFICADO WHERE OPCAO=" & OPCAO & " ORDER BY OPCAO"
ENTAO ELE DA UM ERRO :
Erro de sintaxe (vírgula) na expressão de consulta 'opcao = Casais and procura =casal, mulherand estado =sp and data between #24/5/2003# and #27/5/2003#'.
A VARIAVEL OPCAO ESTA DANDO UM REQUEST.QUERYSTRING("OPCAO") ONDE TEM AS 3 OPCOES QUE PODE SER SELECIONADA......
COMO FAÇO PARA QUE QUANDO ESCOLHA AS TRES OPÇOES NAO CADASTRE COM A VIRGULA ENTRE AS OPÇOES.... OU ALGUM JEITO DE FAZER A CONSULTA NO CAMPO MESMO TENDO AS VIRGULAS NA PESQUISA......
Select *
Started By
Marcos Sanches
, 27/05/2003, 13:35
1 reply to this topic
#1 Marcos Sanches
Posted 27/05/2003, 13:35
#2
Posted 27/05/2003, 15:02
hmmm o jeito seria vc dar 1 nome pra cada campo do form por exemplo: item1, item2, item3.
e fazer um tratamento para cada itemX q ele trouxer acrescenta na instruçao:
sql = "Select * from tabela where "
if request("item1") <> "" then
sql = sql & "campo = " & request("item1") & " "
end if
if request("item2") <> "" then
'condição pra ele usar o "or" de acordo com o request anterior
if request("item1") <> "" then
sql = sql & " or "
end if
sql = sql & "campo = " & resquest("item2") & " "
end if
if request("item3") <> "" then
if request("item1") <> "" and request("item2") <> "" then
sql = sql & " or "
end if
sql = sql & "campo = " & resquest("item3") & " "
end if
espero ter ajudado...
e fazer um tratamento para cada itemX q ele trouxer acrescenta na instruçao:
sql = "Select * from tabela where "
if request("item1") <> "" then
sql = sql & "campo = " & request("item1") & " "
end if
if request("item2") <> "" then
'condição pra ele usar o "or" de acordo com o request anterior
if request("item1") <> "" then
sql = sql & " or "
end if
sql = sql & "campo = " & resquest("item2") & " "
end if
if request("item3") <> "" then
if request("item1") <> "" and request("item2") <> "" then
sql = sql & " or "
end if
sql = sql & "campo = " & resquest("item3") & " "
end if
espero ter ajudado...
Marcelo Pereira Ramos Rodrigues
Delphi Developer
CCE da Amazônia
Delphi Developer
CCE da Amazônia
2 user(s) are reading this topic
0 membro(s), 2 visitante(s) e 0 membros anônimo(s)