Visual Basic - error en cnn.execute

Life is soft - evento anual de software empresarial
 
Vista:

error en cnn.execute

Publicado por lorenzo medina garcia (9 intervenciones) el 02/09/2007 21:05:34
he obtenido la siguiente respuesta de otro usuario para dr de baja a multiples registros que cumplan una condicion, pero cundo lo ejecuto me da el siguiente error "

objeto requerido " y se situa en cnn.execute (consulta)


consulta = "delete from citas where diadelafecha betwen ""&text5.text"" and ""&text6.text"""
cnn.execute (consulta)

gracias por vuestro consejo

Lorenzo Medina Garcia
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:error en cnn.execute

Publicado por El Lute (1 intervención) el 02/09/2007 22:54:11
pero... le hiciste la conexión al cnn?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:error en cnn.execute

Publicado por lorenzo medina garcia (9 intervenciones) el 02/09/2007 22:59:52
tengo el siguiente texto, ayudame por favor, estoy empezando y existen algunas cosas que no consigo entender

Private Sub Command2_Click()
sdblocation = "c:\manosbellas.mdb"
Set dbTest = OpenDatabase(sdblocation)
Set rscitas = dbTest.OpenRecordset("citas", dbOpenTable)
consulta = "delete from citas where diadelafecha betwen ""&text5.text"" and ""&text6.text"""
rscita.execute = consulta
en el text5, tengo una fecha y en el text6, otra

que hago mal
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:error en cnn.execute

Publicado por smokalot (203 intervenciones) el 03/09/2007 09:02:19
Hola,

Correcto, pero mete el format("YYYY/mm/dd") a la fecha para evitarte problemas de configuracion regional del cliente (user) o del mismo servidor de bbdd.

Suerte,

SMK
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:no consigo borrar los resgistros

Publicado por lorenzo medina garcia (9 intervenciones) el 03/09/2007 11:48:07
los dsatos de "fechadelacita" EN LA bd estan como "fecha/hora", y capturo los datos en un text. que a continuacion os informo de como estan capturados.

Private Sub Text5_KeyPress(KeyAscii As Integer)
Const Number$ = "0123456789." ' only allow these characters

If KeyAscii <> 8 Then
If InStr(Number$, Chr(KeyAscii)) = 0 Then
KeyAscii = 0
Exit Sub
End If
End If

If Len(Text5) = 2 Or Len(Text5) = 5 Then
Text5 = Text5 & "/"
Text5.SelStart = Len(Text5)
End If
End Sub

Private Sub Text6_KeyPress(KeyAscii As Integer)
Const Number$ = "0123456789." ' only allow these characters

If KeyAscii <> 8 Then
If InStr(Number$, Chr(KeyAscii)) = 0 Then
KeyAscii = 0
Exit Sub
End If
End If

If Len(Text6) = 2 Or Len(Text5) = 5 Then
Text6 = Text6 & "/"
Text6.SelStart = Len(Text6)
End If
End Sub

sdblocation = "c:\manosbellas.mdb"
Set dbTest = OpenDatabase(sdblocation)
Set rscitas = dbTest.OpenRecordset("citas", dbOpenTable)
rscitas = "delete from citas where diadelafecha betwen ""&text3.text"" and ""&text4.text.text"""


si en vez de poner text.. pongo una fecha determinada " 02/08/2007", NO TEN PROBLEMA ME BORRA LOS REGISTROS DESEADOS, pero con ls text no consigo, que hago mal, gracias por vuestros consejos
un saludo

Lorenzo Medina Garcia
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:error en cnn.execute

Publicado por lorenzo medina garcia (9 intervenciones) el 03/09/2007 12:18:12
si he puesto tu codigo y me da el siguiente error

" too few parameters expected n1" en la linea donde esta el execute, en mi nota anterior explico como lo hago con los codigos que he puesto
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:error en cnn.execute

Publicado por lorenzo medina garcia (9 intervenciones) el 04/09/2007 00:35:45
perdona he vuelto a mirar el codigo y no encuentro el problema a continuacion te
indico los pasos que he seguido por si encuentras algo mal.

el campo fechadelacita en la BD estan con fecha/hora.
lo datos se introducen en los text, y estos son los codigos

indiPrivate Sub Text5_KeyPress(KeyAscii As Integer)
Const Number$ = "0123456789." ' only allow these characters

If KeyAscii <> 8 Then
If InStr(Number$, Chr(KeyAscii)) = 0 Then
KeyAscii = 0
Exit Sub
End If
End If

If Len(Text5) = 2 Or Len(Text5) = 5 Then
Text5 = Text5 & "/"
Text5.SelStart = Len(Text5)
End If
End Sub


Private Sub Text6_KeyPress(KeyAscii As Integer)
Const Number$ = "0123456789." ' only allow these characters

If KeyAscii <> 8 Then
If InStr(Number$, Chr(KeyAscii)) = 0 Then
KeyAscii = 0
Exit Sub
End If
End If

If Len(Text6) = 2 Or Len(Text6) = 5 Then
Text6 = Text6 & "/"
Text6.SelStart = Len(Text6)
End If
End Sub

declarion de variable:
public dbtest as Dao.database

y cuando puo en el boto para borrar los registro el siguiente codigo:

Set dbTest = OpenDatabase("c:\manosbellas.mdb")
dbTest.Execute "Delete From citas Where diadelafecha Between #" & Text5 & "# And #" & Text6 & "#" , te ruego me digas si ves el error,

te ruego que como a ti te funciona bien, me envies el codigo por e-mail, para poder comprobar donde me e equivocado ydoy la solucion.
mi email. "[email protected]"

un saludo y perdona lo torpe que soy pero no veo el error. gracias

Lorenzo Medna Garcia
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar