Foros del Web » Programación para mayores de 30 ;) » Programación General » Visual Basic clásico »

Error "Insert to" en vb6

Estas en el tema de Error "Insert to" en vb6 en el foro de Visual Basic clásico en Foros del Web. Acudo nuevamente a ustedes para haber si me aclaran un poco este problema... Bueno el problema este Solo me marca ese error al momento de ...
  #1 (permalink)  
Antiguo 22/01/2010, 17:22
Avatar de buxforever  
Fecha de Ingreso: abril-2009
Ubicación: Tijuana, B.C
Mensajes: 107
Antigüedad: 15 años
Puntos: 0
Error "Insert to" en vb6

Acudo nuevamente a ustedes para haber si me aclaran un poco este problema...

Bueno el problema este



Solo me marca ese error al momento de ingresar los datos a la base de datos..

y al momento de depurar me manda a esto



y el codigo es este....

Código vb:
Ver original
  1. Option Explicit
  2.  
  3.  
  4. Dim cn As ADODB.Connection
  5. Dim rs As ADODB.Recordset
  6. Dim sql As String
  7.  
  8. Private Sub Ejecutar_Comando( _
  9.     sql As String, _
  10.     conexion As ADODB.Connection)
  11.    
  12.     ' nuevo Command
  13.    Dim Comando As New ADODB.Command
  14.    
  15.     ' propiedades
  16.    With Comando
  17.         .ActiveConnection = cn ' Especificar la conexión a usar
  18.        .CommandText = sql ' Especificar el Contenido del comando
  19.        .Execute ' ejecutar el command '''Aqui es donde me marca el error
  20.        Set Comando = Nothing
  21.        
  22.         ' Cargar los datos en la grilla
  23.        Call Cargar_Grilla(RAlumno.DataGrid1)
  24.     End With
  25. End Sub
  26.  
  27. ' cargar la grilla con el contenido del rs
  28. Private Sub Cargar_Grilla(grilla As Object)
  29.     rs.Requery
  30.     Set grilla.DataSource = rs
  31. End Sub
  32.  
  33.  
  34. Private Sub Form_Load()
  35.    
  36.     ' Abre la conexión, y el Recordset
  37.    Call Iniciar_Conexion
  38.  
  39.     Set rs = New ADODB.Recordset
  40.     With rs
  41.         .CursorLocation = adUseClient
  42.         .Open "tabla", cn, adOpenStatic, adLockReadOnly, adCmdTable
  43.     End With
  44.    
  45.     Call Cargar_Grilla(RAlumno.DataGrid1)
  46.    
  47.    
  48. End Sub
  49.  
  50. ' Inicializa la conexión ADO
  51. Public Sub Iniciar_Conexion()
  52.  
  53.     If cn Is Nothing Then
  54.        Set cn = New ADODB.Connection
  55.        
  56.        With cn
  57.          .CursorLocation = adUseClient
  58.          .Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
  59.                 App.Path & "\Basetemp.mdb" & ";Persist Security Info=False"
  60.         End With
  61.     End If
  62. End Sub
  63.  
  64. ' Cierra un Recordset
  65. Sub Cerrar_Recordset(rst As ADODB.Recordset)
  66.     If Not DataGrid1.DataSource Is Nothing Then
  67.            
  68.        Set DataGrid1.DataSource = Nothing
  69.     End If
  70.     If Not rst Is Nothing Then
  71.        If rst.State = adStateOpen Then rst.Close
  72.        Set rst = Nothing
  73.     End If
  74. End Sub
  75.  
  76. ' Cierra el objeto Connection
  77. Sub cerrar_Conexion(pCn As ADODB.Connection)
  78.     If Not pCn Is Nothing Then
  79.        If pCn.State = adStateOpen Then pCn.Close
  80.        Set pCn = Nothing
  81.     End If
  82. End Sub
  83.  
  84. Private Sub Form_Unload(Cancel As Integer)
  85.     Call Cerrar_Recordset(rs)
  86.     Call cerrar_Conexion(cn)
  87. End Sub
  88.  
  89. Private Sub KewlButtons1_Click()
  90.  
  91.     If Text66.Text = "" Or _
  92.        Text1.Text = "" Or _
  93.        Text68.Text = "" Then
  94.          MsgBox "Datos incompletos", vbCritical, "Error ..."
  95.          Exit Sub
  96.     End If
  97.    
  98.     sql = "Insert Into tabla " _
  99.                      & "(No Control,Parentesco,Edad) " _
  100.                      & "Values ('" & Text66.Text & _
  101.                      "','" & Text1.Text & "'," _
  102.                      & Text68.Text & ")"
  103.    
  104.     Call Ejecutar_Comando(sql, cn)
  105. End Sub

Se lo agradecere mucho al que ayude...
  #2 (permalink)  
Antiguo 22/01/2010, 19:52
Avatar de buxforever  
Fecha de Ingreso: abril-2009
Ubicación: Tijuana, B.C
Mensajes: 107
Antigüedad: 15 años
Puntos: 0
Respuesta: Error "Insert to" en vb6

Ya solucione el problema .....

Muchas Gracias de todos modos

Etiquetas: vb
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 00:05.