1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
| dim sel
Set conn1 = CreateObject("ADODB.Connection")
Set conn2 = CreateObject("ADODB.Connection")
Set rst1 = CreateObject("ADODB.Recordset")
Set rst2 = CreateObject("ADODB.Recordset")
conn1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\bd1.mdb"
conn2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\bd2.mdb"
conn1.open
conn2.open
sql1 = "select Nom from tblClient;"
sql2 = "select Nom from tblClient;"
rst1.open sql1,conn1
rst2.open sql2,conn2
rst1.movefirst
while not rst1.eof
rst2.movefirst
while not rst2.eof
if (rst1.fields("Nom").value <> rst2.fields("Nom").value) then
if (rst2.eof - 1) then
msgbox("INSERT")
sel = "INSERT INTO rst1.tblClient ( Nom, Code, Nom, Code ) SELECT rst1.tblClient.Nom, rst1.tblClient.Code, rst2.tblClient.Nom, rst2.tblClient.Code FROM rst2.tblClient LEFT JOIN rst1.tblClient ON rst2.tblClient.Nom = rst1.tblClient.Nom WHERE (((rst1.tblClient.Nom) Is Null));"
rst2.close
rst2.open sel,conn2
end if
rst2.movenext
else
while not rst2.eof
rst2.movenext
wend
end if
wend
rst1.movenext
wend
conn1.close
conn2.close
'rst1 = nothing
'rst2 = nothing
Const ForReading = 1, ForWriting = 2, ForAppend = 8
Set WshShell = WScript.CreateObject("WScript.Shell")
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:\temp\Log.txt", ForWriting ,true)
f.write("Traitement terminé le ")
f.write(day(date))
f.write(" ")
f.write(monthname(month(date)))
f.write(" à ")
f.write(time) |
Partager