I'm connecting succesfully to an Oracle 10g DB with an the Microsoft ODBC for Oracle driver.
Regular queries without parameters work fine, but parameterized queries act as if the parameters aren't getting passed in.
ex.
--this works fine
Select * from tbl1 where column1 = 'test'
--this doesn't
select * from tbl1 where column1 = ?
--odbc string parameter 'test'
Here's what my connection string looks like:
"Driver={Microsoft ODBC for Oracle}; " & _
"CONNECTSTRING=(DESCRIPTION=" & _
"(ADDRESS=(PROTOCOL=TCP)" & _
"(HOST=" & pstrServer & ")(PORT=" & pintPort.ToString & "))" & _
"(CONNECT_DATA=(SERVICE_NAME=" & pstrPhysicalName & "))); " & _
"uid=" & pstrUserName & ";pwd=" & pstrPassword & ";"
And I'm adding parameters to my ODBC command like this:
arrOdbcParam(index) = New OdbcParameter("@paramName", paramValue)
...
cmd.Parameters.AddRange(arrOdbcParam)
Forgive the partialy copied, somewhat pseuedo code.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…