Sign in to follow this  
JonW

Repeating OLE DB Parameters

Recommended Posts

Hi, I have an SQL query like the following: SELECT * FROM WorldObjects WHERE (((@x1 >= BOUND_MIN_X AND @x1 <= BOUND_MAX_X) OR (BOUND_MIN_X >= @x1 AND BOUND_MIN_X <= @x2)) AND ((@y1 >= BOUND_MIN_Y && @y1 <= BOUND_MAX_Y) OR (BOUND_MIN_Y >= @y1 AND BOUND_MIN_Y <= @y2))) As you can see there are 4 named parameters in the query: @x1, @x2, @y1, and @y2. The problem I'm having is that I wish to run the query against a SQL Server database using the C/C++ OLE DB API, and apparently, OLE DB does not support named parameters. Instead, it appears I have to do this: SELECT * FROM WorldObjects WHERE (((? >= BOUND_MIN_X AND ? <= BOUND_MAX_X) OR (BOUND_MIN_X >= ? AND BOUND_MIN_X <= ?)) AND ((? >= BOUND_MIN_Y AND ? <= BOUND_MAX_Y) OR (BOUND_MIN_Y >= ? AND BOUND_MIN_Y <= ?))) which references the parameters by ordinal. However, this would mean that I would have to specify the 4 parameters multiple times so the database would know which parameters to use, if I understand correctly. Is my understanding of OLE DB's use of parameters correct? And is there any way to run this query without repeating parameters? Thanks!! [Edited by - JonW on July 21, 2009 8:37:56 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this