我正在尝试将一个Access数据库中的一行数据导入另一个数据库。我不想导入整个表,仅导入指定的行。我的代码现在可以正常工作,但是它很笨拙,我觉得必须有更好的方法:
Dim strSQL As String
Dim importRs As DAO.Recordset
Dim destRs As DAO.Recordset
Dim importDb As Database
Dim destDb As Database
Set importDb = OpenDatabase(filepath)
Set destDb = CurrentDb
strSQL = "SELECT * FROM tblAO WHERE AOID = " & AOID
Set importRs = importDb.OpenRecordset(strSQL)
strSQL = "INSERT INTO tblAO VALUES(" & importRs.Fields("AOID").Value & ", '" & importRs.Fields("AOName") & "' , '" & importRs.Fields("Description") & "' ," & importRs.Fields("Default") & "," & importRs.Fields("MILCON").Value & "," & importRs.Fields("SUST").Value & ")"
destDb.Execute strSQL
有什么方法可以干净地导入整行数据吗?还是一种更好的方法,除了循环遍历每一行之外,还可以导入多行?我要导入的其他数据具有许多列和多个行,并且我不希望我的代码变慢或难以阅读。任何帮助将不胜感激!