Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

COPY DATA FROM ONE DATABASE TO ANOTHER

Status
Not open for further replies.

pelagic

Programmer
Nov 7, 2002
97
US
Hi there,
I tried to copy data from one data base to another. Sometimes it works pretty well, but sometimes not all data are copy over. Could Anyone tell me what really happend?

This is what I have:
Dim cn1 As ADODB.Connection
Dim strCn1 As String
Dim strPathtoDB1 As String

Dim cn2 As ADODB.Connection
Dim strCn2 As String
Dim strPathtoDB2 As String

Set cn1 = New ADODB.Connection
Set cn2 = New ADODB.Connection

'DATABASE ON SERVER
strPathtoDB1 = "\\Server\Database1.mdb"
cn1.CursorLocation = adUseClient
strCn1 = "PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strPathtoDB1 & _
";Jet OLEDB:Database Password=mypassword"
cn1.Open strCn1

'LOCAL HARD DISK
strPathtoDB2 = App.Path & "\Database2.mdb"
cn2.CursorLocation = adUseClient
strCn2 = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strPathtoDB2 & _
";Jet OLEDB:Database Password=mypassword"
cn2.Open strCn2

'perform the data transfer from local to server
cn2.Execute "INSERT INTO Table1 IN " & _
"'" & strPathtoDB1 & "'" & " SELECT * FROM Table2"

Thanks

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top