Autor Tema: Conectar Visual Basic con Base en SQL Server 2005 (SOLUCIONADO)  (Leído 23349 veces)

0 Usuarios y 1 Visitante están viendo este tema.

omarinho23

  • Megabyte
  • ***
  • Mensajes: 105
  • Reputación: +0/-1
    • Ver Perfil
Re:Conectar Visual Basic con Base en SQL Server 2005 (duda)
« Respuesta #15 en: Enero 22, 2010, 01:41:26 pm »
ay! >,< ... le kite igual ahora me bota otro error xD en el imsmo lugar :S

[[ conversion failed when converting datetime from character string ]]

[note]
    Case AGREGAR_REGISTRO
       
        cnn.Execute "INSERT INTO Clientes " & "(voucher,dia,contacto,razonsocial,nºderuc,direccion,inspector,tipodecertificado,cantidad,precio,total,codigodebarra,cit,nºdeplaca,nºdemotor,nºdeserieochasis,nºdecertificado,totalvoucher,boletaofactura,mes,lista,asignacion,observacion) VALUES('" & _
                                 Text1(1) & "','" & _
                                 Date & _
                                 Text1(3) & "','" & _
                                 Text1(4) & "','" & _
                                 Text1(5) & "','" & _
                                 Text1(6) & "','" & _
                                 Text1(7) & "','" & _
                                 Text1( & "','" & _
                                 Text1(9) & "','" & _
                                 Text1(10) & "','" & _
                                 Text1(11) & "','" & _
                                 Text1(12) & "','" & _
                                 Text1(13) & "','" & _
                                 Text1(14) & "','" & _
                                 Text1(15) & "','" & _
                                 Text1(16) & "','" & _
                                 Text1(17) & "','" & _
                                 Text1(18) & "','" & _
                                 Text1(19) & "','" & _
                                 Text1(20) & "','" & _
                                 Text1(21) & "','" & _
                                 Text1(22) & "','" & _
                                 Text1(23) & "','" & "')"
                                 

[/note]

ssccaann43

  • Moderador
  • Terabyte
  • *****
  • Mensajes: 970
  • Reputación: +97/-58
    • Ver Perfil
    • Sistemas Nuñez, Consultores y Soporte, C.A.
Re:Conectar Visual Basic con Base en SQL Server 2005 (duda)
« Respuesta #16 en: Enero 22, 2010, 02:32:28 pm »
Coloca:
convert(datetime, date, 103)
Miguel Núñez.

omarinho23

  • Megabyte
  • ***
  • Mensajes: 105
  • Reputación: +0/-1
    • Ver Perfil
Re:Conectar Visual Basic con Base en SQL Server 2005 (duda)
« Respuesta #17 en: Enero 22, 2010, 02:39:17 pm »
ahora cuando pongo ese convert me sale error de "procedimiento sub o funcion no definido"


Código: [Seleccionar]
    Case AGREGAR_REGISTRO
       
        cnn.Execute "INSERT INTO Clientes " & "(voucher,dia,contacto,razonsocial,nºderuc,direccion,inspector,tipodecertificado,cantidad,precio,total,codigodebarra,cit,nºdeplaca,nºdemotor,nºdeserieochasis,nºdecertificado,totalvoucher,boletaofactura,mes,lista,asignacion,observacion) VALUES('" & _
                                 Text1(1) & "','" & _
                                 Dateconvert(DateTime, Date, 103) & _
                                 Text1(3) & "','" & _
                                 Text1(4) & "','" & _
                                 Text1(5) & "','" & _
                                 Text1(6) & "','" & _
                                 Text1(7) & "','" & _
                                 Text1(8) & "','" & _
                                 Text1(9) & "','" & _
                                 Text1(10) & "','" & _
                                 Text1(11) & "','" & _
                                 Text1(12) & "','" & _
                                 Text1(13) & "','" & _
                                 Text1(14) & "','" & _
                                 Text1(15) & "','" & _
                                 Text1(16) & "','" & _
                                 Text1(17) & "','" & _
                                 Text1(18) & "','" & _
                                 Text1(19) & "','" & _
                                 Text1(20) & "','" & _
                                 Text1(21) & "','" & _
                                 Text1(22) & "','" & _
                                 Text1(23) & "','" & "')"



y me señala el Text1 con azul... :S
« última modificación: Enero 22, 2010, 02:41:54 pm por omarinho23 »

omarinho23

  • Megabyte
  • ***
  • Mensajes: 105
  • Reputación: +0/-1
    • Ver Perfil
Re:Conectar Visual Basic con Base en SQL Server 2005 (duda)
« Respuesta #18 en: Enero 22, 2010, 02:44:03 pm »
si lo se! ya lo puse! pero igual sale el error xD

omarinho23

  • Megabyte
  • ***
  • Mensajes: 105
  • Reputación: +0/-1
    • Ver Perfil
Re:Conectar Visual Basic con Base en SQL Server 2005 (duda)
« Respuesta #19 en: Enero 22, 2010, 02:48:29 pm »
trate de agregarle o cambiarle de formato

Format(valor(0), "mm/dd/yyyy hh:mm:ss")

pero igual me salta el error anterior xD

ssccaann43

  • Moderador
  • Terabyte
  • *****
  • Mensajes: 970
  • Reputación: +97/-58
    • Ver Perfil
    • Sistemas Nuñez, Consultores y Soporte, C.A.
Re:Conectar Visual Basic con Base en SQL Server 2005 (duda)
« Respuesta #20 en: Enero 22, 2010, 02:49:30 pm »
a ver...


Código: [Seleccionar]

cnn.Execute "INSERT INTO Clientes " & "(voucher,dia,contacto,razonsocial,nºderuc,direccion,inspector,tipodecertificado,cantidad,precio,total,codigodebarra,cit,nºdeplaca,nºdemotor,nºdeserieochasis,nºdecertificado,totalvoucher,boletaofactura,mes,lista,asignacion,observacion) VALUES('" & Text1(1) & "',Convert(DateTime," & Date & ", 103),'" & Text1(3) & "','" & _


« última modificación: Enero 22, 2010, 02:55:04 pm por ssccaann43 »
Miguel Núñez.

omarinho23

  • Megabyte
  • ***
  • Mensajes: 105
  • Reputación: +0/-1
    • Ver Perfil
Re:Conectar Visual Basic con Base en SQL Server 2005 (duda)
« Respuesta #21 en: Enero 22, 2010, 03:03:28 pm »
Código: [Seleccionar]
        cnn.Execute "INSERT INTO Clientes " & "(voucher,dia,contacto,razonsocial,nºderuc,direccion,inspector,tipodecertificado,cantidad,precio,total,codigodebarra,cit,nºdeplaca,nºdemotor,nºdeserieochasis,nºdecertificado,totalvoucher,boletaofactura,mes,lista,asignacion,observacion) VALUES('" & _
                                 Text1(1) & "','" & _
                                 Text1(2) & "',Convert(DateTime,'" & Date & "', 103),'" & _
                                 Text1(3) & "','" & _
                                 Text1(4) & "','" & _
                                 Text1(5) & "','" & _
                                 Text1(6) & "','" & _
                                 Text1(7) & "','" & _
                                 Text1(8) & "','" & _
                                 Text1(9) & "','" & _
                                 Text1(10) & "','" & _
                                 Text1(11) & "','" & _
                                 Text1(12) & "','" & _
                                 Text1(13) & "','" & _
                                 Text1(14) & "','" & _
                                 Text1(15) & "','" & _
                                 Text1(16) & "','" & _
                                 Text1(17) & "','" & _
                                 Text1(18) & "','" & _
                                 Text1(19) & "','" & _
                                 Text1(20) & "','" & _
                                 Text1(21) & "','" & _
                                 Text1(22) & "','" & _
                                 Text1(23) & "','" & "')"

lo puse asi y me sale otro :S error! a verdad me olvide comentarte la fecha se agrega sola :S osea como te explico le puse este cod para q se generara solo

es un label

Código: [Seleccionar]
Sub Agregar()
   
    ' Acción
    FrmEditCarmen.ACCION = AGREGAR_REGISTRO
   
    FrmEditCarmen.lblFecha = Format(Date, "dd/mm/yyyy")
    ' Abre el Form
    FrmEditCarmen.Show 1
End Sub

y cuando pongo agregar el registro se genera solo la fecha actual y se agrega en un textbox el cual no se puede modificar porq lo e bloqueado y cuando pongo grabar me pone el error

[[  there are fewer columns in the INSERT statement than values specified in the VALUES clause, the number of values in the VALUES clause must match the number of columns specified in the INSERT statement ]]

 :'(

ssccaann43

  • Moderador
  • Terabyte
  • *****
  • Mensajes: 970
  • Reputación: +97/-58
    • Ver Perfil
    • Sistemas Nuñez, Consultores y Soporte, C.A.
Re:Conectar Visual Basic con Base en SQL Server 2005 (duda)
« Respuesta #22 en: Enero 22, 2010, 03:08:17 pm »
Te da error porque tienes 23 campos en el Insert y en el value insertas 24 valores...! Saca esto: Text1(2) & "',  y deja el Convert(...........

Espero haberme explicado bien...!
Miguel Núñez.

omarinho23

  • Megabyte
  • ***
  • Mensajes: 105
  • Reputación: +0/-1
    • Ver Perfil
Re:Conectar Visual Basic con Base en SQL Server 2005 (duda)
« Respuesta #23 en: Enero 22, 2010, 05:45:52 pm »
bueno quite el campo demas y de nuevo me sale el error de
procedimiento Sub o Function no definido

y me señala este error

Citar
        cnn.Execute "INSERT INTO Clientes " & "(voucher,dia,contacto,razonsocial,nºderuc,direccion,inspector,tipodecertificado,cantidad,precio,total,codigodebarra,cit,nºdeplaca,nºdemotor,nºdeserieochasis,nºdecertificado,totalvoucher,boletaofactura,mes,lista,asignacion,observacion) VALUES('" & _
                                 Text1(1) & "','" & _
                                 Convert(DateTime, "& Date &", 103) & _
                                 Text1(3) & "','" & _
                                 Text1(4) & "','" & _
                                 Text1(5) & "','" & _
                                 Text1(6) & "','" & _
                                 Text1(7) & "','" & _
                                 Text1(8) & "','" & _
                                 Text1(9) & "','" & _
                                 Text1(10) & "','" & _
                                 Text1(11) & "','" & _
                                 Text1(12) & "','" & _
                                 Text1(13) & "','" & _
                                 Text1(14) & "','" & _
                                 Text1(15) & "','" & _
                                 Text1(16) & "','" & _
                                 Text1(17) & "','" & _
                                 Text1(18) & "','" & _
                                 Text1(19) & "','" & _
                                 Text1(20) & "','" & _
                                 Text1(21) & "','" & _
                                 Text1(22) & "','" & _
                                 Text1(23) & "','" & "')"


ssccaann43

  • Moderador
  • Terabyte
  • *****
  • Mensajes: 970
  • Reputación: +97/-58
    • Ver Perfil
    • Sistemas Nuñez, Consultores y Soporte, C.A.
Re:Conectar Visual Basic con Base en SQL Server 2005 (duda)
« Respuesta #24 en: Enero 22, 2010, 07:02:10 pm »
Lo estas haciendo mal... El convert(datetime, va dentro del query... por ello es el error...!

Colocare aqui nuevamente como debes hacerlo, y asi tal cual pegalo en tú proyecto...!


Código: [Seleccionar]
cnn.Execute "INSERT INTO Clientes (voucher, dia, contacto, razonsocial, nºderuc, direccion, inspector, tipodecertificado, cantidad, precio, total, codigodebarra, cit, nºdeplaca, nºdemotor, nºdeserieochasis, nºdecertificado, totalvoucher, boletaofactura, mes, lista, asignacion, observacion) VALUES('" & Text1(1) & "',Convert(DateTime, " & Date & ", 103),'" & Text1(3) & "','" & Text1(4) & "','" & Text1(5) & "','" & Text1(6) & "','" & Text1(7) & "','" & Text1(8) & "','" & Text1(9) & "','" & Text1(10) & "','" & Text1(11) & "','" & Text1(12) & "','" & Text1(13) & "','" & Text1(14) & "','" & Text1(15) & "','" & Text1(16) & "','" & Text1(17) & "','" & Text1(18) & "','" & Text1(19) & "','" & Text1(20) & "','" & Text1(21) & "','" & Text1(22) & "','" & Text1(23) & "')"
Miguel Núñez.

omarinho23

  • Megabyte
  • ***
  • Mensajes: 105
  • Reputación: +0/-1
    • Ver Perfil
Re:Conectar Visual Basic con Base en SQL Server 2005 (duda)
« Respuesta #25 en: Enero 22, 2010, 07:12:55 pm »
ya lo copie grax. si ya no sale ese error pero ahora sale este error :S

[[  there are fewer columns in the INSERT statement than values specified in the VALUES clause, the number of values in the VALUES clause must match the number of columns specified in the INSERT statement ]]
 :'( :'( :'(
Código: [Seleccionar]
        cnn.Execute "INSERT INTO Clientes " & "(voucher,dia,contacto,razonsocial,nºderuc,direccion,inspector,tipodecertificado,cantidad,precio,total,codigodebarra,cit,nºdeplaca,nºdemotor,nºdeserieochasis,nºdecertificado,totalvoucher,boletaofactura,mes,lista,asignacion,observacion) VALUES('" & _
                                 Text1(1) & "',Convert(DateTime, " & Date & ", 103),'" & _
                                 Text1(3) & "','" & _
                                 Text1(4) & "','" & _
                                 Text1(5) & "','" & _
                                 Text1(6) & "','" & _
                                 Text1(7) & "','" & _
                                 Text1(8) & "','" & _
                                 Text1(9) & "','" & _
                                 Text1(10) & "','" & _
                                 Text1(11) & "','" & _
                                 Text1(12) & "','" & _
                                 Text1(13) & "','" & _
                                 Text1(14) & "','" & _
                                 Text1(15) & "','" & _
                                 Text1(16) & "','" & _
                                 Text1(17) & "','" & _
                                 Text1(18) & "','" & _
                                 Text1(19) & "','" & _
                                 Text1(20) & "','" & _
                                 Text1(21) & "','" & _
                                 Text1(22) & "','" & _
                                 Text1(23) & "','" & "')"

ssccaann43

  • Moderador
  • Terabyte
  • *****
  • Mensajes: 970
  • Reputación: +97/-58
    • Ver Perfil
    • Sistemas Nuñez, Consultores y Soporte, C.A.
Re:Conectar Visual Basic con Base en SQL Server 2005 (duda)
« Respuesta #26 en: Enero 22, 2010, 07:15:42 pm »
No copiaste todo tal cual!! Despues del Text1(23) & "'    DEBES CERRAR... al colocar una "," COMA... Indica que viene otro CAMPO... COLOCALO TAL CUAL AMIGO... Caramba es tal dificil?????
Miguel Núñez.

ssccaann43

  • Moderador
  • Terabyte
  • *****
  • Mensajes: 970
  • Reputación: +97/-58
    • Ver Perfil
    • Sistemas Nuñez, Consultores y Soporte, C.A.
Re:Conectar Visual Basic con Base en SQL Server 2005 (duda)
« Respuesta #27 en: Enero 22, 2010, 07:16:46 pm »
Copia el codigo, NO LO EDITES, NO TRATES DE ARREGLARLO... Copialo tal cual y dime si te da error!!!!

Código: [Seleccionar]
cnn.Execute "INSERT INTO Clientes (voucher, dia, contacto, razonsocial, nºderuc, direccion, inspector, tipodecertificado, cantidad, precio, total, codigodebarra, cit, nºdeplaca, nºdemotor, nºdeserieochasis, nºdecertificado, totalvoucher, boletaofactura, mes, lista, asignacion, observacion) VALUES('" & Text1(1) & "',Convert(DateTime, " & Date & ", 103),'" & Text1(3) & "','" & Text1(4) & "','" & Text1(5) & "','" & Text1(6) & "','" & Text1(7) & "','" & Text1(8) & "','" & Text1(9) & "','" & Text1(10) & "','" & Text1(11) & "','" & Text1(12) & "','" & Text1(13) & "','" & Text1(14) & "','" & Text1(15) & "','" & Text1(16) & "','" & Text1(17) & "','" & Text1(18) & "','" & Text1(19) & "','" & Text1(20) & "','" & Text1(21) & "','" & Text1(22) & "','" & Text1(23) & "')"
Miguel Núñez.

omarinho23

  • Megabyte
  • ***
  • Mensajes: 105
  • Reputación: +0/-1
    • Ver Perfil
Re:Conectar Visual Basic con Base en SQL Server 2005 (duda)
« Respuesta #28 en: Enero 22, 2010, 07:27:13 pm »
AYYYY  ;D

JAJAJA
gracias! :D ssccaann sry por fastidiar xD .. solucionaste el problema! :D muxas gracias! :D por todo! :D

 :D

ssccaann43

  • Moderador
  • Terabyte
  • *****
  • Mensajes: 970
  • Reputación: +97/-58
    • Ver Perfil
    • Sistemas Nuñez, Consultores y Soporte, C.A.
Re:Conectar Visual Basic con Base en SQL Server 2005 (duda)
« Respuesta #29 en: Enero 22, 2010, 07:28:42 pm »
wao, ya me tenias al borde de la locura... Estaba mirando por la ventana para lanzarme... Jajajaja... Nah mentira... Bueno, si necesitas más ayuda solo postea, pero recuerda, has las cosas como acá se te indican... Poco a poco se van corrigiendo los errores...

Saludos, ya me voy de la oficina, estoy cansado y creo que merezco un par de cervezas...
Miguel Núñez.