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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to stop my db query

Status
Not open for further replies.

yujan

IS-IT--Management
Aug 28, 2003
2
TW
I'm developing an application with big database content. Submitting unreasonable query criteria may result in a long database query time. How to stop the query when I got the interrupt message.
 
There are many *cancel* methods. Which API are you using?

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
The thing is the SQL query could not be done by thread, and I had tried the timer but not working. Here is the sample code I use:

///Create database connection
CDatabase *m_dbPacsDB;
m_dbPacsDB=new CDatabase();
TRY
{
m_dbPacsDB->Open"pacs_testdb",FALSE,FALSE,"ODBC;UID=USER;PWD=PASSWORD");
}
CATCH(CDBException, e)
{
TCHAR tcErr[1024];
if (e->GetErrorMessage(tcErr, 1024))
AfxMessageBox(tcErr, MB_OK);
e->Delete();
return FALSE;
}
END_CATCH


CString strSQL;
strSQL.Format("select * from studylevel where studydatetime between '2003-07-01 00:00:00.000' and '2003-09-01 23:59:59.999'");
CCSMDPatStuSerSet rsPatStuSerSet(m_dbPacsDB);
/////The program hang in here.....
rsStudyLevelSet.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL,CRecordset::none);
while(!rsStudyLevelSet.IsEOF())
{
.....
rsStudyLevelSet.MoveNext();
}
rsStudyLevelSet.Close();

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The Recordset could not be closed when it's processing the querying job.
 
use:
m_dbPacsDB->Cancel();
//note what to cancel you should execute query in a
//separate thread

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top