将记录从一个表更新到位于不同文件夹中的另一个表。
Dim connection As New ADODB.Connection
Dim strConnection As String
Dim pathPrincipal As String
Dim pathUpdate As String 'External data base to update with TablePrincipal
Dim strSQL As String
pathPrincipal = "D:\DBFs"
strConnection = "Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=" & PathPrincipal
connection.Open strConnection
If connection.State <> adStateOpen Then Exit Sub
'正确的 :)
strSQL="UPDATE TablePrincipal#DBF" & " A INNER JOIN " & "TableUpdate#DBF" & " B ON A.ID = B.ID SET A.X=B.X, A.Y=B.Y"
'Execute
connection.Execute strSQL, n, adCmdText
以前的代码可以完美运行.....
但我的问题是当两个 DBF 不在同一个文件夹中但我正在尝试这不是其他方法时
'No working for external DBF :'( :(
strSQL = "UPDATE TablePrincipal#DBF A INNER JOIN" & _
" OPENROWSET('MSDASQL','Driver={Microsoft dBase Driver (*.dbf)}; DBQ=" & _
pathUpdate & "; SourceType = DBF ','SELECT * FROM TableUpdate#DBF') B" & _
" ON A.ID=B.ID SET A.X=B.X, A.Y=B.Y"
任何人都可以帮助我.....请!!!!为我的英语道歉:)