CRecordset: predefined queries with parameters that have an apostrophe 
Author Message
 CRecordset: predefined queries with parameters that have an apostrophe

I am trying to retrieve information from my SQL database about a
specific hotel. This hotel has an apostrophe in the name.
('Jorgenson's Inn'). I am constructing a string to pass to the open
function:

wsprintf(query, "sr_u_hotel
(69,'Preferred','Yes','HLN  ','Jorgenson''s Inn & Suites', '1714
Eleventh Avenue', '', 'Helena', 'MT','66555','406.442.1770',
'406.449.0155', '', '', 'Yes','65.00','','','','','')");

Then I execute this line of code to open the connection:
Open(CRecordset::dynaset, "{CALL " + query + "}",
CRecordset::readOnly);

I have used the double single quote, but I am still getting an error:
First-chance exception in SkyRes.exe (ODBC32.DLL): 0xC0000005: Access
Violation.

I use this same piece of code to run all of my queries and it appears
that this error only happens when one of the parameters has an
apostrophe.

In the CRecordset::IsOpen() function it errors out on this line:
AFX_ODBC_CALL(::SQLNumResultCols(m_hstmt, &nCols));
The value of the m_hstmt = 0Xcccccccc.

Any help would be appreciated. I think the problem is that it is not
preparing my SQL statement properly because of the apostrophe, but I
do not know how to fix it.

Jen



Tue, 05 Oct 2004 03:57:52 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. CRecordset-Predefined query calling VB code

2. CRecordset - parameterized predefined queries/stored procedures

3. Opening Parameter Based Access Query as CRecordSet

4. Predefined Queries and DAO

5. DoFieldExchange and Predefined Queries (ODBC)

6. Predefined Queries (ODBC)

7. Problem sorting predefined query using ODBC

8. Having problem with CRecordset under Visual C++ 7.

9. Here's an easy question, having to do with the CRecordSet Class

10. Having problem with CRecordset under Visual C++ 7.

11. CRecordset & queries

12. CRecordset join query issues

 

 
Powered by phpBB® Forum Software