- Home
·
- Active Server Pages
·
- This script allow to load data between two data bases on line. It opens two parallel connections, a
This script allow to load data between two data bases on line. It opens two parallel connections, a
This script allow to load data between two data bases on line. It opens two parallel connections, and it synchronizes two recorset that works
Rate This script allow to load data between two data bases on line. It opens two parallel connections, a
(2(2 Vote))
<% Dim tbl
'table name
tbl="some_table"
'Opening Database 1.
Set db_cnx1 = Server.CreateObject("ADODB.Connection")
db_path="DBQ=" & server.mappath("db1.mdb")
db_cnx1.Open "DRIVER={Microsoft Access Driver (*.mdb)}; " & db_path
sql1="Select * from " & tbl
on error resume next
Set db_rcdst1=db_cnx1.execute(sql1)
'Opening Database 2
Set db_cnx2=server.createobject("adodb.connection")
db_path="DBQ=" & server.mappath("db2.mdb")
db_cnx2.Open "DRIVER={Microsoft Access Driver (*.mdb)}; " & db_path
'Starting table & recorsets iteraction
db_rcdst1.MoveFirst
all_flds = db_rcdst1.Fields.Count-1
all_records = 0
db_cnx2.BeginTrans
Do While Not db_rcdst1.EOF
all_records=all_records+1
Sqlz=""
For nCounter=0 to all_flds
current_value = db_rcdst1(nCounter)
If IsNull(current_value) Then current_value=Chr(32)
If VarType(current_value) > 6 Then
Sqlz=Sqlz & Chr(39) & current_value & "',"
Else
current_value=Replace(current_value, Chr(44), Chr(46) )
Sqlz=Sqlz & current_value & ","
End If
Next
a = Left(Sqlz, Len(Sqlz)-1)
sql1="Insert Into " & tbl & " values(" & a & ")"
Set db_rcdst2=db_cnx2.execute(sql1)
db_rcdst1.movenext
loop
If db_cnx2.Errors.Count = 0 Then
db_cnx2.CommitTrans
Response.Write"<br>"
Response.Write all_records & " rows inserted in destiny."
Else
db_cnx2.RollbackTrans
Response.Write " Unexpected error. Operation canceled"
End If
db_cnx2.close
set db_cnx2=nothing
db_cnx1.close
set db_cnx1 = nothing %>
</BODY></HTML>
This script allow to load data between two data bases on line. It opens two parallel connections, a Comments
No comments yet — be the first to post one!
Post a Comment