Guest_imported
New member
- Jan 1, 1970
- 0
The problem is that I want to develop a dynamic SQL statement for a search engine. The SQL statement in question is:
Select * From CustomerInfo where (((CustomerInfo.Firstname=?) AND(CustomerInfo.Lastname=?) And(CustomerInfo.CustomerID=?));
In some cases I will not be provided with the customer ID, in which case only the first two "where" clauses will be sent as the SQL statement. i.e.
Select * From CustomerInfo where (((CustomerInfo.Firstname=?) AND(CustomerInfo.Lastname=?));
The problem arises if only the customer ID is provided, in which case a search always fails. If only the last name is provided, the search also fails. However, if the firstname and lastname are provided, then searches are sucessful.
I have three parameters in this scenario. Must I change the amount of parameters on the fly? I open the recordSet with the following statement:
m_pSet->Open(AFX_DB_USE_DEFAULT_TYPE, Str);
where Str, is the variable SQL statement.
Select * From CustomerInfo where (((CustomerInfo.Firstname=?) AND(CustomerInfo.Lastname=?) And(CustomerInfo.CustomerID=?));
In some cases I will not be provided with the customer ID, in which case only the first two "where" clauses will be sent as the SQL statement. i.e.
Select * From CustomerInfo where (((CustomerInfo.Firstname=?) AND(CustomerInfo.Lastname=?));
The problem arises if only the customer ID is provided, in which case a search always fails. If only the last name is provided, the search also fails. However, if the firstname and lastname are provided, then searches are sucessful.
I have three parameters in this scenario. Must I change the amount of parameters on the fly? I open the recordSet with the following statement:
m_pSet->Open(AFX_DB_USE_DEFAULT_TYPE, Str);
where Str, is the variable SQL statement.