Hi, I'm trying to run a query with VBA to connect to an Oracle database, but am running into issues when I try to add in a parameter. This statement is essentially what I'm trying to run, but I can't figure out how to put in a parameter:
(where myparam is a parameter
This is the code I'm trying, but it throws errors:
It looks like it is trying to find the column myvar in the database and not using it as a parameter. I know I probably need to throw an identifier in the connection string so it knows to use it as a parameter, but I don't know what it would be, and google has surprisingly little on using actual parameters in VBA.
Code:
SELECT * FROM database WHERE MY_COLUMN=myparam
This is the code I'm trying, but it throws errors:
Code:
query.CommandText = "SELECT * FROM database WHERE MY_COLUMN=myparam"
query.CommandType = adCmdText
' is this wrong? I'm trying for it to be a 5 char long string
query.Parameters.Append query.CreateParameter("myparam", adChar, adParamInput, 5, cell.Value)
oracleConnection.Open mConnectionString
query.ActiveConnection = oracleConnection
Set rst = query.Execute
...