border

Miembros:
Mensajes:
Temas:
Online:

Ultimo Miembro:

 
 

Cuenta Bancaria en EEUU
  #1 (permalink)  
Antiguo 16-12-2007, 12:34:11
Junior Member
Site Admin
 
Registrado: oct 2007
Posts: 25
iratxe_83 Valoración +2
Predeterminado 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.
Responder Con Cita
  #2 (permalink)  
Antiguo 16-12-2007, 15:54:52
Avatar de acalanto
Moderador
 
Registrado: dic 2002
Ubicación: Madrid
Posts: 4.307
acalanto ha deshabilitado la reputación
Predeterminado

Inicialmente trataría de eliminar el parámetro DISTINCT. Si aún así no responde correctamente, yo añadiría la claúsuña WHERE paso a paso, hasta detectar en que lugar ponemos algo que bo le gusta..

La única manera de descubrir el lugar que contiene un error de sintáctico es agotar las posibilidades.
__________________
Un cordial saludo
-Acalanto-

Madrid - España

Visual Basic
Videos Programacion
Foro Programacion
Tutoriales Programacion
Responder Con Cita
Respuesta


Herramientas
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Trackbacks are habilitado
Pingbacks are habilitado
Refbacks are habilitado


Temas Similares
Tema Autor Foro Respuestas Último Mensaje
problemas con la sentencia insert iratxe_83 Visual Basic 6.00 11 18-11-2007 16:58:17
Problemas con mi sentencia SQL ikki_26 PHP 1 16-07-2007 18:42:52
problemas al redondear decimal en sentencia sql caroso77 Visual Basic 6.00 3 25-06-2007 15:53:29
Sentencia SQL DeNiro Visual Basic 6.00 3 28-02-2007 17:23:29
Sentencia en SQL macdroopy Visual Basic 6.00 1 23-02-2007 16:48:56


La franja horaria es GMT. Ahora son las 05:10:56.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
A vBSkinworks Design

Alojado en el servicio Premium de Masquewebs | Diseño mejorado por MasqueWebs

right