
28/08/2006, 09:13
|
 | | | Fecha de Ingreso: junio-2006 Ubicación: Buenos Aires, Argentina
Mensajes: 53
Antigüedad: 18 años, 9 meses Puntos: 0 | |
te mando un pequeño ejemplo con bases acces, suerte
Dim Cn1 As ADODB.Connection
Dim Cn2 As ADODB.Connection
Dim rs As ADODB.Recordset
Dim cmd As ADODB.Command
Private Sub Form_Load()
'conectas base local
Set Cn1 = New ADODB.Connection
With Cn1
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "c:\xxx\base.mdb;Persist Security Info=False"
.CommandTimeout = 30
.ConnectionTimeout = 30
.Open
End With
'conectas base en red
Set Cn2 = New ADODB.Connection
With Cn2
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "z:\xxx\base.mdb;Persist Security Info=False"
.CommandTimeout = 30
.ConnectionTimeout = 30
.Open
End With
'seleccionas datos de base en red
Set rs = New ADODB.Recordset
With rs
.ActiveConnection = Cn2
.CursorLocation = adUseClient
.CursorType = adOpenKeyset
.Source = "select * from tabla"
.Open
'haces un bucle para ver los datos e ir pasandolos
Do While Not rs.EOF
'insertas los registros en base local
Set cmd = New ADODB.Command
With cmd
.ActiveConnection = Cn1
.CommandType = adCmdText
.CommandText = "insert into tabla values(rs!campo1, rs!campo2)"
.Execute
End With
Set cmd = Nothing
rs.MoveNext
Loop
End Sub
End With |