Visualizzazione dei risultati da 1 a 6 su 6

Discussione: errore query

  1. #1
    Utente di HTML.it
    Registrato dal
    Mar 2004
    Messaggi
    654

    errore query

    ciao a tutti perchè mi dà questo errore ?

    'Errore di sintassi (operatore mancante) nell'espressione della query'


    set adoRs = Server.CreateObject("ADODB.Recordset")

    sSql = "Select * from tblLeggi where "

    Dim mioArray, i
    mioArray=split(valore, " ")

    For i = 0 to Ubound(mioArray)

    sSql= sSql & "key = '" & mioArray(i) &"'"

    next

    adoRs.open sSql, adoConn, 3, 3




  2. #2
    PRova a stampare la query e verificare cosa restituisce.

  3. #3
    Utente di HTML.it
    Registrato dal
    Mar 2004
    Messaggi
    654
    grazie Weppos stampa questo "Select * from tblLeggi where key = 'data'key = 'buono' "

    quindi manca un end oppure un or vero?


  4. #4
    codice:
    set adoRs = Server.CreateObject("ADODB.Recordset") 
    
    sSql = "Select * from tblLeggi where 1=1 " 
    
    Dim mioArray, i 
    mioArray=split(valore, " ") 
    
    For i = 0 to Ubound(mioArray) 
    
    sSql= sSql & " AND key = '" & mioArray(i) &"'" 
    
    next 
    
    adoRs.open sSql, adoConn, 3, 3

  5. #5
    AND o OR a seconda di cosa vuoi fare.

  6. #6
    Scusa,
    ma guarda che manca un 'and' o un 'or' alla fine della tua concatenazione

    codice:
    For i = 0 to Ubound(mioArray)
    
    sSql= sSql & "key = '" & mioArray(i) &"'" 
    sSql = sSQL & "or "
    next
    Altrimenti concateni key = n key = x ecc..


Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.