Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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?
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
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