>我下面的代码可以将数据更新和内部联接为数据库中的另一个表,它也只使用一个连接字符串,因为它们都在同一个数据库中。
Dim connstring1 As String
connstring1 = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=AMP.accdb"
Dim conn1 As OleDbConnection = New OleDbConnection(connstring1)
Dim updatescardrate As String = "UPDATE scard INNER JOIN Employee_Records ON scard.controlnumber = Employee_Records.controlnumber SET scard.rate = Employee_Records.rate"
Dim cmdupdatescardrate As New OleDbCommand(updatescardrate, conn1)
conn1.Open()
cmdupdatescardrate.ExecuteNonQuery()
conn1.Close()
预期成果示例说明:
UPDATE Table scard.column1 '(this is from connection1, database: AMP.accdb)'
and JOIN data from Table criteria.column3 '(this is from connection2, database: IMS.accdb)'
连接 1:
Dim connstring1 As String
connstring1 = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=AMP.accdb"
连接 2:
Dim connstring2 As String
connstring2 = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=IMS.accdb"
预期成果示例说明:
UPDATE Table scard.column1 '(this is from connection1, database: AMP.accdb)'
and JOIN data from Table criteria.column3 '(this is from connection2, database: IMS.accdb)'
最简单的方法是在第一个数据库中创建一个到第二个数据库的链接表。您可以像使用第一个表一样使用这两个表。