Query hangs using CRecordset::Open()

Query hangs using CRecordset::Open()

Post by Jim Casazz » Thu, 10 Dec 1998 04:00:00



Hello,
When I make the following query call using CRecordset::Open, the function
never returns. I am trying to find duplicate records in the database. When I
run the query in MS Access, the results are returned immediately. All other
queries using CRecordset::Open in the application work fine. Has anyone
experienced this problem or am I doing something incorrectly?

 sprintf(sqlQuery,"SELECT DISTINCTROW [Artist ID] FROM [WCAZ_MasterList]
WHERE ((([Artist ID]) In
                             (SELECT [Artist ID] FROM [WCAZ_MasterList] As
Tmp GROUP BY [Artist ID],[Song Title]
                             HAVING Count(*)>1  And [Song Title] =
[WCAZ_MasterList].[Song Title])))");
 if(CRecordset::IsOpen())
    CRecordset::Close();
 CRecordset::Open(AFX_DB_USE_DEFAULT_TYPE,sqlQuery,CRecordset::none);

Thanks in advance,

Jim Casazza
CAZ Media
http://www.cazmedia.com/mmi - the coolest music on the net

 
 
 

Query hangs using CRecordset::Open()

Post by Cornelia Muelle » Sat, 12 Dec 1998 04:00:00


Hi Jim,

first I must say, that my english is very bad. Acctually I try learn ist  and so
I hope that you can understand me. (a little bit??? please! ;-)) )

Sometime I have the same problem with Recordset::Open(). It happen when I use
ID's in my query. Try it with following code for the query.

// change the ID in a character "umwand"
// without this, the Open statement is incorrectly
sprintf(umwand,"%d",p_RecGesamt->m_ID);

// Now, you can set the query call for Recordset::Open()
// p_RecTeil is my Recordset
CString  strSQL = p_RecTeil->GetDefaultSQL() +
      "WHERE [ID] = " + umwand +
      "And [Teilprojekt] = '" + m_TeilProjekt + "'";

// And now, you ca open the Recordset with Open
// Use the arguments AFX_DB ... and strSQL, because strSQL is the query call
ok1 = p_RecTeil->Open(AFX_DB_USE_DEFAULT_TYPE, strSQL);
 if (ok1) ..... // ok :-)

Cornelia


> Hello,
> When I make the following query call using CRecordset::Open, the function
> never returns. I am trying to find duplicate records in the database. When I
> run the query in MS Access, the results are returned immediately. All other
> queries using CRecordset::Open in the application work fine. Has anyone
> experienced this problem or am I doing something incorrectly?

>  sprintf(sqlQuery,"SELECT DISTINCTROW [Artist ID] FROM [WCAZ_MasterList]
> WHERE ((([Artist ID]) In
>                              (SELECT [Artist ID] FROM [WCAZ_MasterList] As
> Tmp GROUP BY [Artist ID],[Song Title]
>                              HAVING Count(*)>1  And [Song Title] =
> [WCAZ_MasterList].[Song Title])))");
>  if(CRecordset::IsOpen())
>     CRecordset::Close();
>  CRecordset::Open(AFX_DB_USE_DEFAULT_TYPE,sqlQuery,CRecordset::none);

> Thanks in advance,

> Jim Casazza
> CAZ Media
> http://www.cazmedia.com/mmi - the coolest music on the net


 
 
 

1. CRecordset::Open() hangs

Hi, there

I have a visual FoxPro table and a backup of it in a subfolder like so:

g:\whzb\angeb2.dbf
g:\whzb\recent\angeb2.dbf

one is an exact copy of the other.
when I try to open these tables with:

        record_set_in_old->Open(CRecordset :: snapshot, "SELECT * FROM
angeb2");
        record_set_in_new->Open(CRecordset :: snapshot, "SELECT * FROM
recent\\angeb2");

(the CRecordset objects have been successfully created with new)
the first one is opened successfully, but the attempt to open the second
causes the program to hang.

This happens only on one of several tables, and not always. The table itself
should be OK, because I can work on it with VFP.
If I swap the above open calls the hang again happens on the second call, so
it is obviously not the table itself, which causes the problem.

Any ideas what's wrong here?

TIA
Robert

2. How to revert back from SQL 6.5 SP5 to SQL 6.5 SP4

3. Calling a stored procedure from VC++ using CRecordset::Open using output paramet

4. CIM new group

5. Opening a Parameterised Access Query as CRecordSet

6. Trouble with local cube and Analysis Services SP3

7. Opening Parameter Based Access Query as CRecordSet

8. Newbie Question: Why even the "sa" cannot read all the tables? (the letter is about 20 rows in full sreen)

9. CRecordset CanUpdate query failure for Open in read write mode

10. Bug in MFC v.5 - CRecordset::Open using CLongBinary and GetDefaultSQL() override

11. Opening a Parameterised Access Query as CRecordSet

12. Using CRecordset::AddNew() and CRecordset::Edit() with IDENTITY fields