I'd rather not rewrite the database layer to use OO4O, if at all
possible. If there a way to use bind variables (ie. SELECT x FROM y
WHERE z = :v) in ADO?
Thanks for any input.
Bob Burgess
Montreal, Canada
Just use ADO's parameters collection and a question mark (?) as a bind
variable in your SQL. Here's an example from the docs:
Dim objCon As NEW ADODB.Connection
Dim objCmd As NEW ADODB.Command
Dim prEmpno As NEW ADODB.Parameter
Dim prEname As NEW ADODB.Parameter
...
objCmd.ActiveConnection = objCon
objCmd.CommandType = adCmdText
' Create and append the parameters to the command object
Set prEmpno = objCmd.CreateParameter("prEmpno", adSmallInt,
adParamInput, ,8521)
' prEname is bound to a NVARCHAR column in the EMP table
Set prEname = objCmd.CreateParameter("prEname", adBSTR, adParamInput, ,
"Joe")
objCmd.Parameters.Append prEmpno
objCmd.Parameters.Append prEname
' Enabling the NDatatype property indicates to the provider
' that one or more of the bound parameters is of N datatype
objCmd.Properties("NDatatype") = TRUE
' Assume column ENAME in table EMP is of NVARCHAR type
objCmd.CommandText = "INSERT INTO EMP (EMPNO, ENAME) VALUES (?, ?)"
' Execute the SQL
objCmd.Execute
' It is a good idea to disable the property after execute as the same
command
' object may be used for a different SQL statement
objCmd.Properties("NDatatype") = FALSE
-- tojo
so instead of
SELECT x FROM y WHERE z = ?
being passed you can actually pass something like
where z = namedparameter.
"tojo" <TomJor...@hotmail.com> wrote in message
news:MPG.174376807...@news.t-online.de...
Thank you, Tom. After my post, I kept searching and found another
good example here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iisref/html/psdk/asp/iiwadata.asp
(Scroll down to the heading "Improving Queries with the Command
Object".)
--Bob
It's sad, but no. ADO replaces the question marks with param values in
the order you defined them. I think JDBC works the same way (but dont
quote me). OO4O is clearly superior in this area.
-- Tom
I'm going to play a bit with.net and the Oracle client for that so I'll see
how that goes.
--
Niall Litchfield
Oracle DBA
Audit Commission UK
*****************************************
Please include version and platform
and SQL where applicable
It makes life easier and increases the
likelihood of a good answer
******************************************
"tojo" <t...@hotmail.com> wrote in message
news:MPG.1746f71ed...@news.t-online.de...