我从数据库中查询数据,需要将结果放入另一个Access数据库中。
我有获取数据,填充数据表,然后连接到新数据库的代码,但是我没有获取数据。 Access表已填充(24000行以上),但数据是通用数据,而不是数据表中的数据。
Dim wTable As New DataTable
Dim connString1 = "Provider=IBMDADB2;Database=...;"
Dim connString2 = "Provider=Microsoft.ACE.OLEDB.12.0..."
'sWebi is the SELECT query from the 1st database
'Webi_Connection is the saved connection string = connString1
Using conn As New OleDbConnection(connString1), adapter As New OleDbDataAdapter(sWEBI, Webi_Connection)
adapter.AcceptChangesDuringFill = False
adapter.Fill(wTable)
End Using
Dim insSQL As String = "INSERT INTO tblWEBI_Results (CumbID, CumbIDSequenceNumber, LastName, FirstName, CorrectedBirthDate, Control, Suffix, Account, CustomerPSUnique, CustomerName) VALUES (@1, @2, @3, @4, @5, @6, @7, @8, @9, @10)"
Using conn As New OleDbConnection(connString2), adapter As New OleDbDataAdapter, insertCommand As New OleDbCommand(insSQL, DBConnection)
adapter.InsertCommand = insertCommand
conn.Open()
insertCommand.Parameters.AddWithValue("@1", "CumbID")
insertCommand.Parameters.AddWithValue("@2", "CumbIDSequenceNumber")
insertCommand.Parameters.AddWithValue("@3", "LastName")
insertCommand.Parameters.AddWithValue("@4", "FirstName")
insertCommand.Parameters.AddWithValue("@5", "CorrectedBirthDate")
insertCommand.Parameters.AddWithValue("@6", "Control")
insertCommand.Parameters.AddWithValue("@7", "Suffix")
insertCommand.Parameters.AddWithValue("@8", "Account")
insertCommand.Parameters.AddWithValue("@9", "CustomerPSUnique")
insertCommand.Parameters.AddWithValue("@10", "CustomerName")
adapter.Update(wTable)
conn.Close()
End Using
我得到了期望的行,但是数据本身未显示。所以,我想我只是从数据表中丢失了对数据的正确调用,对吧?