Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Insert Macro vba

how to make an insert in oracle database via macro.
I am not able to make the connection with the Oracle database.

What is the syntax for conexion via vba macro?

2 Replies
Not applicable
Author

hi,

try with this code in VBscript

dim sConn, oConn

Set oConn = CreateObject("ADODB.Connection")

sConn = "Provider=MSDAORA;User ID="yourlogin";Password="yourpassword";Data Source="your data source";OLEDB.NET=true;SPPrmsLOB=true;Persist Security Info=False;"

oConn.Open sConn

sSQL="your request"

oConn.Execute(sSQL)

oConn.Close

Set oConn = Nothing

hugmarcel
Specialist
Specialist

Sub DeleteFrom_Oracle_DB
  Dim objADO
  Dim strSQL
 
  'Create ADO Object
  Set objADO = CreateObject("ADODB.Connection")

  'Establish a connection: See https://www.connectionstrings.com/oracle/ for valid connection types
  objADO.Open "Provider=OraOLEDB.Oracle;Data Source=<service_name>;User Id=<user>[<schema>];Password=<password>"

  'Set SQL to e.g. delete rows
  strSQL="DELETE FROM <schema>.<table> WHERE <field> LIKE '<your_value>'"

  'Begin Transaction
  objADO.BeginTrans

  'Execute Transaction
  objADO.Execute strSQL, RecordsAffected
  objADO.CommitTrans
  objADO.Close

  Msgbox RecordsAffected
End Sub