
Estoy tratando de guardar en una base de datos los datos introducidos en 6 List distintos.

Para ello, utilizo el siguiente código:
Código PHP:
Dim CnN As New ADODB.Connection
Dim Rst As New ADODB.Recordset
Private Sub Command4_Click()
z = 0
Do While z < lstCodigo.ListCount
CnN.Execute "INSERT INTO ventas(Cliente, CantidadVendida, Detalle, Precio , PrecioTotal, NumeroFactura, Codigo, Fecha, Unidad) VALUES ('" & txtCliente & "', " & Val(lstCantidad.List(z)) & ", '" & lstDetalle.List(z) & "', " & Val(lstPrecio.List(z)) & ", " & Val(lblTotal) & ", " & Val(txtNumeroFactura) & ", " & Val(lstCodigo.List(z)) & ", '" & txtFecha & "', " & lstUnidades.List(z) & " )"
MsgBox "guardado"
Loop
End Sub
De hecho, he probado usando el INSERT de otra forma:
Código PHP:
Dim CnN As New ADODB.Connection
Dim Rst As New ADODB.Recordset
Private Sub Command4_Click()
z = 0
Do While z < lstCodigo.ListCount
m = " Insert into ventas (NumeroFactura , Cliente , Codigo , Detalle , Precio , Fecha, Unidad, CantidadVendida, PrecioTotal ) values (" & Val(txtNumeroFactura) & " , ' " & txtCliente & " ' , " & lstCodigo.List(z) & " , ' " & lstDetalle.List(z) & " ' , ' " & lstPrecio.List(z) & " ' , ' " & txtFecha & " ', " & lstUnidades.List(z) & ", " & lstCantidad.List(z) & " , " & lstTotal.List(z) & " )"
conexion_basedatos.Execute m 'conexion_basedatos está definida en un Modulo'
MsgBox "guardado"
Loop
End Sub
¿A alguien se le ocurre en dónde puede estar el problema?
¡Desde ya, muchas gracias!