Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic SQL Statements For RecordSets

Status
Not open for further replies.

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.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top