首页 > 解决方案 > 将本地 MS Access 数据库中的表记录插​​入 Oracle 表

问题描述

我正在尝试将本地 Access 数据库中的记录插入到 Oracle 表中。两个表中的相同字段。

如果不需要的话,我不想遍历这些行。我必须编写代码才能连接到 oracle 数据库。只是不确定选择名为“RET_PARTS”的本地 Access 表并将该数据插入名为 RET2_PARTS_ORACLE 的 Oracle 表的代码”

    Sub subFastUpload()
`enter code here`On Error GoTo Err_subFastUpload

  `enter code here`Dim intlength As Integer
  `enter code here`intlength = 8
  `enter code here`Dim strServer As String
  strServer = "MARS"
 
  Const maxItems = 500
   
  Dim dbs As DAO.Database
  Dim rst As DAO.Recordset
  Dim objRst As New ADODB.Recordset
  Dim objCon As New ADODB.Connection
  Dim objCmd As New ADODB.Command
  Dim strTable As String
  Dim intCount As Integer
  
  Set dbs = CurrentDb()
  Set rst = dbs.OpenRecordset("Ret2_Parts")
  
  Dim mars_pass As String
  'mars_pass = InputBox("Enter MaRS Password")
   mars_pass = "XXXXXXX"
  intCount = 1
  If strServer = "MARS" Then
    strTable = Environ("UserName") & ".RET2_PARTS_ORACLE"
    objCon.ConnectionString = "Provider=OraOLEDB.Oracle;Data Source=MARSNEW.123;User ID=" & Environ("UserName") & ";Password=" & mars_pass & ";"
    strTable = Environ("UserName") & ".RET2_PARTS_ORACLE"
  End If
  objCon.Open
  objCmd.ActiveConnection = objCon
  objCmd.CommandType = adCmdText
  objCmd.Properties("PLSQLRSet") = False
  While Not rst.EOF
    If intCount = 1 Then
    strSQL = "Select * from RET2_Parts"
    Debug.Print strSQL

标签: vbaoraclems-accessoracle11g

解决方案


推荐阅读