Hi,
I am trying to export data from excel sheet to a table on a oracle database but couldn't get the code below to work
It keeps throwing error at 2nd strSQL line. I seek help from forum to get this to work. thanks.
I am trying to export data from excel sheet to a table on a oracle database but couldn't get the code below to work
It keeps throwing error at 2nd strSQL line. I seek help from forum to get this to work. thanks.
VBA Code:
Sub ExportXLtoOracle()
Dim con As ADODB.Connection
Dim conStr As String
Dim r As Long, c As Long, rMax As Long
Dim strSQL As String
Dim ws1 As Excel.Worksheet
Set ws1 = ThisWorkbook.Worksheets("Team")
Dim ExpRange As Range
Set ExpRange = ws1.Range("A2:D6")
conStr = "Provider=OraOLEDB.Oracle.1;Password=1234;Persist Security Info=True;User ID=ABCDE;Data Source=EMD21"
Set con = New ADODB.Connection
con.Open conStr
For lngRow = 1 To 10
strSQL = "Insert Into ABCDE.DATA_TEMP" '/
strSQL = strSQL & "'" & Range(ExpRange, 1).Value & "', " '/ JAVA
strSQL = strSQL & "'" & Range(ExpRange, 2).Value & "', " '/ ORACLE
strSQL = strSQL & "'" & Range(ExpRange, 3).Value & "', " '/ C++
strSQL = strSQL & "'" & Range(ExpRange, 4).Value & "' " '/ C#
con.Execute strSQL
Next
con.Close
Set con = Nothing
End Sub