problemas con la sentencia sql Hola a todos:
tengo un pequeño problema que no se como solucionar, haber si alguien sabe porque me esta fallando, muchisimas gracias.
Tengo un formulario en el cual el usuario puede introducir si quiere codigo, materia,familia,institucion,persona,geografico y signatura.
El problema lo tengo a la hora de buscar esos campos en la base de datos. Me da el error no se han especificado valores para algunos de los parametros requeridos (error -2147217904).
Aun introduciendo todos los campos me sale este error y no se porque. Debugueando mi sentencia sql tiene lo siguiente:
SElect distinct * from UNIDAD_DOCUMENTAL where CODIGO = '13.14 SAN JUAN (LARRAZABAL)' and MATERIAS = 'vanesa' and FAMILIAS = 'HOSTELERIA' and INSTITUCIONES = 'ESCUELAS DE LA SALLE' and PERSONAS = 'PEREA' and GEOGRÁFICOS = 'Anuncibai (Llodio)' and SIGNATURA = 'despedida vane'
El codigo que tengo escrito es:
lleno = False
sql = "SElect distinct * from UNIDAD_DOCUMENTAL where "
If codigo <> "" Then
lleno = True
sql = sql + "CODIGO = '" & codigo & "'"
End If
If materia <> "" Then
If lleno = True Then
sql = sql + " and MATERIAS = '" & materia & "'"
Else
sql = sql + " MATERIAS = '" & materia & "'"
End If
lleno = True
End If
If familia <> "" Then
If lleno = True Then
sql = sql + " and FAMILIAS = '" & familia & "'"
Else
sql = sql + " FAMILIAS = '" & familia & "'"
End If
lleno = True
End If
If institucion <> "" Then
If lleno = True Then
sql = sql + " and INSTITUCIONES = '" & institucion & "'"
Else
sql = sql + " INSTITUCIONES = '" & institucion & "'"
End If
lleno = True
End If
If persona <> "" Then
If lleno = True Then
sql = sql + " and PERSONAS = '" & persona & "'"
Else
sql = sql + " PERSONAS = '" & persona & "'"
End If
lleno = True
End If
If geografico <> "" Then
If lleno = True Then
sql = sql + " and GEOGRÁFICOS = '" & geografico & "'"
Else
sql = sql + " GEOGRÁFICOS = '" & geografico & "'"
End If
lleno = True
End If
If signatura <> "" Then
If lleno = True Then
sql = sql + " and SIGNATURA = '" & signatura & "'"
Else
sql = sql + " SIGNATURA = '" & signatura & "'"
End If
lleno = True
End If
'''''''''''''''''''''''''''''''''''''
'ya tenemos la sentencia sql
'''''''''''''''''''''''''''''''''''''
rs.Open sql, cnn, adOpenDynamic, adLockOptimistic
With rs
If (.BOF And .EOF) Then
MsgBox " imagen dañada"
Else
'visualizar la imagen
rs.MoveFirst
Do Until rs.EOF
'añadimos todo a una lista invisible
' si hay mas de
'una imagen que visualizar
List1.AddItem rs("SIGNATURA")
Loop
End If
End With
rs.Close
End Sub
Muchisimas gracias por vuestra ayuda. |