Visual Basic Foro
Programación => Bases de Datos => Mensaje iniciado por: omarinho23 en Enero 21, 2010, 04:48:10 pm
-
Buenooooo molestando de nuevo a todos =D , jijiji, bueno ice mi conex a sql server 2005 q instale en mi pc
pero me sale error :S no se q estoy aciendo mal, no se si el servidor esta en on o no se q es lo q pasa! alguien me puede guiar .gracias!
el error es
[ sql network interfaces : error locating server/instance specfied ]
Option Explicit
Public Declare Sub InitCommonControls Lib "comctl32" ()
' variables para la conexión y el recordset
''''''''''''''''''''''''''''''''''''''''''''
Public cnn As New ADODB.Connection
Public rs As New ADODB.Recordset
Public ObjItem As ListItem
Sub Main()
On Error Resume Next
Call InitCommonControls
Err.Clear
FrmPrincipalCarmen.Show
End Sub
Public Sub IniciarConexion()
With cnn
.CursorLocation = adUseClient
.Open "Provider=SQLNCLI;Server=SERVIDOR\Administrador;Database=NWINDFINALSQL; Trusted_Connection=yes;"
End With
End Sub
Public Sub CargarListView(LV As ListView, rs As ADODB.Recordset)
On Error GoTo ErrorSub
Dim i As Integer
'limpia el LV
LV.ListItems.Clear
' si hay registros
If rs.RecordCount > 0 Then
' recorre el recordset
While Not rs.EOF
' añade los datos
Set ObjItem = LV.ListItems.Add(, , rs(0))
ObjItem.SubItems(1) = rs!voucher
ObjItem.SubItems(2) = rs!dia
ObjItem.SubItems(3) = rs!contacto
ObjItem.SubItems(4) = rs!razonsocial
ObjItem.SubItems(5) = rs!nºderuc
ObjItem.SubItems(6) = rs!direccion
ObjItem.SubItems(7) = rs!inspector
ObjItem.SubItems(8) = rs!tipodecertificado
ObjItem.SubItems(9) = rs!cantidad
ObjItem.SubItems(10) = rs!precio
ObjItem.SubItems(11) = rs!total
ObjItem.SubItems(12) = rs!codigodebarra
ObjItem.SubItems(13) = rs!cit
ObjItem.SubItems(14) = rs!nºdeplaca
ObjItem.SubItems(15) = rs!nºdemotor
ObjItem.SubItems(16) = rs!nºdeserieochasis
ObjItem.SubItems(17) = rs!nºdecertificado
ObjItem.SubItems(18) = rs!totalvoucher
ObjItem.SubItems(19) = rs!boletaofactura
ObjItem.SubItems(20) = rs!mes
ObjItem.SubItems(21) = rs!lista
ObjItem.SubItems(22) = rs!asignacion
ObjItem.SubItems(23) = rs!observacion
' siguiente registro
rs.MoveNext
Wend
End If
Call ForeColorColumn(&H8000&, 0, FrmPrincipalCarmen.LV)
'Call ForeColorColumn(vbRed, 6, FrmPrincipalcarmen.LV)
Exit Sub
ErrorSub:
If Err.Number = 94 Then Resume Next
End Sub
' cierra
Sub Desconectar()
On Local Error Resume Next
rs.Close
Set rs = Nothing
cnn.Close
Set cnn = Nothing
End Sub
-
Hola...
Verifica en: Inicio -> Panel de Control -> Herramientas Administrativas -> Servicios este cargado el SQL Server 2005. Quizas aparezca como SQL Server EXPRESS.
Luego de estar iniciado, haces lo siguiente.
En un proyecto nuevo en visual basic, ubica el control:
Microsoft ADO Data Control 6.0
Pegalo en un form, e intenta conectarte desde allí a la BD que tienes en el SQL Server 2005. Si la conexión es satisfactoria, pues seleccionas el string de conexión que el ADODC tiene y usalo en tú proyecto.
Saludos.
PD: En Recopilación de Codigo, hay varios string de conexión para SQL Server 2005. Date una vueltita por allí.
-
ola ssccaann bueno como tenia 2 proyec uno en ADODC y otro en ADO bueno estoy utilizando el ADODC ahora q tngo el servidor, pero ahora :S tu crees q sea un problema usar un servidor con red inalambrica ??? y bueno... otra cosa :S estoy utlizando el programa en el servidor y la bd en sql server 2005 , bueno ahora quiero compartirla en red, y cuando comparto la carpeta y el archivo .exe me salen errores y errores diferentes :S una de ellas q esa cuenta invitada no existia :S y otra error de espera... y otra de unos cod :S no capto enserio..
como lo hago o q me recomiendas
-
Hola, la cadena de conexion esta mal en esta parte:
SERVIDOR\Administrador
si queres ver cadenas de conexion te recomiendo esta pagina:
http://www.connectionstrings.com/ (http://www.connectionstrings.com/)
aca te paso la que uso yo siempre con SQL Server 2005.
Provider=SQLOLEDB.1;Persist Security Info=False;User ID=TuUsuario;Password=TuPassword;Initial Catalog=TuBase;Data Source=NOMBREDETUPC\SQLEXPRESS;Connect Timeout=60;
donde TuUsuario es el usuario con el que accedes a la base y TuPassword es el password del usuario,TuBase es el nombre de la base de datos y en NOMBREDETUPC\SQLEXPRESS va el nombre de tu pc seguido de \SQLEXPRESS, eso es necesario en las versiones SQL Express, en la versión enterprise no hace falta y solo va el nombre de la PC...o la IP como quieras...
PD:sacale esos As New en las delaraciones.
saludos.
-
Seba el As New no es problema... Yo lo uso siempre...
omarinho23, usa el string de conex que te da seba... Por cierto es mejor usar ADO y no ADODC, te explique lo del ADODC para que sacaras el string de conexión, no para que lo usaras como tal.
-
bueno tons siguiendo tus consejos... sigo usando ADO bueno, ahora me sale el problema de transformacion de fecha :S " Conversion falied when converting datetime from character string " ... mi formato esta asi [[ Format(Date, "dd/mm/yyyy") ]] como debo ponerlo?
y cuando trato de editar un registro a la hora de guardar tmb me sale el error con la fecha " the conversion of a char data type to a datetime data type resulted in an out-of-range datetime value "
no capto con las fechas! u.u
-
Ve si puedes usar esto...
CONVERT(DATETIME, Date, 103)
Modificacion:
Antes que nada, estas haciendo un select condicionando por fecha?
El campo fecha que tienes en la Base de Datos que tipo de campo es?
Muestrame lo que estas haciendo.
-
donde pongo ese convert(datetime, date, 103) ... lo remplazo con mi format(date, "dd/mm/yyyy")
-
donde pongo ese convert(datetime, date, 103) ... lo remplazo con mi format(date, "dd/mm/yyyy")
Antes que nada, estas haciendo un select condicionando por fecha?
El campo fecha que tienes en la Base de Datos que tipo de campo es?
Muestrame lo que estas haciendo.
-
aer! en la base de datos de sql esta en el formato "datetime"
y bueno mi conex es esta
Option Explicit
Public Declare Sub InitCommonControls Lib "comctl32" ()
' variables para la conexión y el recordset
''''''''''''''''''''''''''''''''''''''''''''
Public cnn As New ADODB.Connection
Public rs As New ADODB.Recordset
Public ObjItem As ListItem
Sub Main()
On Error Resume Next
Call InitCommonControls
Err.Clear
FrmPrincipalCarmen.Show
End Sub
Public Sub IniciarConexion()
With cnn
.CursorLocation = adUseClient
.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=BASEFINAL;Data Source=SERVIDOR"
End With
End Sub
Public Sub CargarListView(LV As ListView, rs As ADODB.Recordset)
On Error GoTo ErrorSub
Dim i As Integer
'limpia el LV
LV.ListItems.Clear
' si hay registros
If rs.RecordCount > 0 Then
' recorre el recordset
While Not rs.EOF
' añade los datos
Set ObjItem = LV.ListItems.Add(, , rs(0))
ObjItem.SubItems(1) = rs!voucher
ObjItem.SubItems(2) = rs!dia
ObjItem.SubItems(3) = rs!contacto
ObjItem.SubItems(4) = rs!razonsocial
ObjItem.SubItems(5) = rs!nºderuc
ObjItem.SubItems(6) = rs!direccion
ObjItem.SubItems(7) = rs!inspector
ObjItem.SubItems(8) = rs!tipodecertificado
ObjItem.SubItems(9) = rs!cantidad
ObjItem.SubItems(10) = rs!precio
ObjItem.SubItems(11) = rs!total
ObjItem.SubItems(12) = rs!codigodebarra
ObjItem.SubItems(13) = rs!cit
ObjItem.SubItems(14) = rs!nºdeplaca
ObjItem.SubItems(15) = rs!nºdemotor
ObjItem.SubItems(16) = rs!nºdeserieochasis
ObjItem.SubItems(17) = rs!nºdecertificado
ObjItem.SubItems(18) = rs!totalvoucher
ObjItem.SubItems(19) = rs!boletaofactura
ObjItem.SubItems(20) = rs!mes
ObjItem.SubItems(21) = rs!lista
ObjItem.SubItems(22) = rs!asignacion
ObjItem.SubItems(23) = rs!observacion
' siguiente registro
rs.MoveNext
Wend
End If
Call ForeColorColumn(&H8000&, 0, FrmPrincipalCarmen.LV)
'Call ForeColorColumn(vbRed, 6, FrmPrincipalcarmen.LV)
Exit Sub
ErrorSub:
If Err.Number = 94 Then Resume Next
End Sub
' cierra
Sub Desconectar()
On Local Error Resume Next
rs.Close
Set rs = Nothing
cnn.Close
Set cnn = Nothing
End Sub
cnn.Execute "UPDATE Clientes set voucher = '" & Text1(1) & _
"', dia = '" & Text1(2) & _
"', contacto = '" & Text1(3) & _
"', razonsocial = '" & Text1(4) & _
"', nºderuc = '" & Text1(5) & _
"', direccion = '" & Text1(6) & _
"', inspector = '" & Text1(7) & _
"', tipodecertificado = '" & Text1(8) & _
"', cantidad = '" & Text1(9) & _
"', precio = '" & Text1(10) & _
"', total= '" & Text1(11) & _
"', codigodebarra = '" & Text1(12) & _
"', cit = '" & Text1(13) & _
"', nºdeplaca = '" & Text1(14) & _
"', nºdemotor = '" & Text1(15) & _
"', nºdeserieochasis = '" & Text1(16) & _
"', nºdecertificado = '" & Text1(17) & _
"', totalvoucher = '" & Text1(18) & _
"', boletaofactura = '" & Text1(19) & _
"', mes = '" & Text1(20) & _
"', lista = '" & Text1(21) & _
"', asignacion = '" & Text1(22) & _
"', observacion = '" & Text1(23) & _
"' where Cod = " & IdRegistro & ""
-
Esperaba que al menos me reflejaras donde muestra el error... Donde haces el select? Quiero ver el Select * from............
-
bueno el selec es este
[note]
Option Explicit
Enum EACCION
AGREGAR_REGISTRO = 0
EDITAR_REGISTRO = 1
End Enum
Public IdRegistro
Public ACCION As EACCION
Private Sub cmdGuardar_Click()
Text1(11).Text = ((Val(Text1(9).Text) * Val(Text1(10).Text)))
Text1(22).Text = ((Val(Text1(11).Text * 0.3) / 1.19))
'Agrega el registro
'''''''''''''''''''''''''''''''
Select Case ACCION
Case EDITAR_REGISTRO
cnn.Execute "UPDATE Clientes set voucher = '" & Text1(1) & _
"', dia = '" & Text1(2) & _
"', contacto = '" & Text1(3) & _
"', razonsocial = '" & Text1(4) & _
"', nºderuc = '" & Text1(5) & _
"', direccion = '" & Text1(6) & _
"', inspector = '" & Text1(7) & _
"', tipodecertificado = '" & Text1(8) & _
"', cantidad = '" & Text1(9) & _
"', precio = '" & Text1(10) & _
"', total= '" & Text1(11) & _
"', codigodebarra = '" & Text1(12) & _
"', cit = '" & Text1(13) & _
"', nºdeplaca = '" & Text1(14) & _
"', nºdemotor = '" & Text1(15) & _
"', nºdeserieochasis = '" & Text1(16) & _
"', nºdecertificado = '" & Text1(17) & _
"', totalvoucher = '" & Text1(18) & _
"', boletaofactura = '" & Text1(19) & _
"', mes = '" & Text1(20) & _
"', lista = '" & Text1(21) & _
"', asignacion = '" & Text1(22) & _
"', observacion = '" & Text1(23) & _
"' where Cod = " & IdRegistro & ""
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) & "','" & _
Format(Date, "dd/mm/yyyy") & _
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) & "','" & "')"
End Select
rs.Requery 1
Call CargarListView(FrmPrincipalCarmen.LV, rs)
DoEvents
Unload Me
Set FrmEditCarmen = Nothing
Exit Sub
ErrorSub:
MsgBox Err.Description
End Sub
Private Sub cmdCancelar_Click()
Unload Me
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyEscape Then
Unload Me
End If
End Sub
Private Sub Text1_Change(Index As Integer)
Text1(22) = Format(Text1(22), "#0.00")
Text1(11) = Format(Text1(11), "#0.00")
Text1(18) = Format(Text1(18), "#0.00")
End Sub
[/note]
y el error se me origina en esta parte [[ cnn.Execute "UPDATE Clientes set voucher = '" & Text1(1) & _ ]] y todo lo q viene abajo hasta terminar el update
-
Ok, alli solo coloca DATE y debería guardar. Quita el format!
-
kite el format y me salio otro error :S [[ unclosed quotation mark after the character string '22/01/2010' ]]
y me sale el error en
[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, "dd/mm/yyyy" & _
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) & "','" & "')"
[/note]
-
Caramba, lee mi post anterior te dije que solo dejaras DATE
Al quitar el format, debes quitar tambien "dd/mm/yyyy".
Y queda Date & _
-
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]
-
Coloca:
convert(datetime, date, 103)
-
ahora cuando pongo ese convert me sale error de "procedimiento sub o funcion no definido"
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
-
si lo se! ya lo puse! pero igual sale el error xD
-
trate de agregarle o cambiarle de formato
Format(valor(0), "mm/dd/yyyy hh:mm:ss")
pero igual me salta el error anterior xD
-
a ver...
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) & "','" & _
-
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
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 ]]
:'(
-
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...!
-
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
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) & "','" & "')"
-
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...!
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) & "')"
-
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 ]]
:'( :'( :'(
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) & "','" & "')"
-
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?????
-
Copia el codigo, NO LO EDITES, NO TRATES DE ARREGLARLO... Copialo tal cual y dime si te da error!!!!
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) & "')"
-
AYYYY ;D
JAJAJA
gracias! :D ssccaann sry por fastidiar xD .. solucionaste el problema! :D muxas gracias! :D por todo! :D
:D
-
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...
-
jajajajaja yo tmb keria tirarme x la ventana! xD jajajaja muchas gracias! y sry por contradecir xD jojojojo
ok muchas gracias! y Salud! ;D
-
lo del tema del As New no lo digo yo porque se me ocurrio, o porque lo invente, esta en varios lugares y manuales que cuando enseñan a declarar objetos, dicen que no usar el As New, ya que este puede no andar en algunas maquinas, y aunque no lo crean una ves se dio el caso de que tuve que corregir un programa que tiraba error y nadie sabia porque era, porque estaba todo bien, y al final era porque estaba delcarando un recordset arriba con As New. aparte dicen por ahi en internet que al declarar asi se tarda mucho mas tiempo, cada vez que usas una variable con As New el visual basic internamente se fija si ya esta instanciada.
saludos.
-
ntonces con que reemplazo los As New porque de todas maneras me va a pedir un reemplazo ???
-
Seba dice que en vez de hacer:
Dim RsClientes as New ADODB.Recordset
hagas
Dim RsClientes as ADODB.Recordset
-
O.o creo que era mas facil cambiar el formato de fecha de la pc y de la base de datos!!!
por eso yo no ocupo el insert into!!!!!!!!!
mejor el .addnew
-
Recien me engancho estuve en otros lares.
Se que ya resolviste pero a ver si te sirve este tip en el manejo de fecha.
Nota: El Insert es PERFECTO para hacer inserciones.
Y con el tema de la fecha que es una joda lo he resuelto de la siguiente forma (solo usalo si funciona bien con SQL Server porque con Firebird va de maravilla)
Dim MiFecha as string
MiFecha = Format(XXXXXXX, "YYYY/MM/DD") <---- Aqui le dije adios al dolor de cabeza.
Las XXXX es por el control o variable que tengas la fecha, y el formato es año, mes, dia y asi "creo yo" ninguna BD te dara problemas y va bien con los campos timestamp. Es mas, si lo quieres grabar con la hora solo has Format(XXXX, "YYYY/MM/DD HH:MM:SS"
Luego en tu inserción usas la variable MiFecha que en el caso de Firebird acepta perfectamente que envies la fecha como string e imagino que SQL Server tambien.
Lo de la sintaxis ya te lo corrigio Miguel
Saludos