problem with Open() method
-
Hi, I have an application in which I am loading data from a database (in this specific case a large database) into a grid in my GUI. So, I open the query into a recordset using the Open method as follows: sQuery.Format(_T("SELECT DISTINCT D.fieldA, DC.fieldB from TableDC DC, TableD D WHERE D.fieldA = DC.fieldA AND D.No = '3’ ORDER BY DC.fieldB")); if(!Open(AFX_DB_USE_DEFAULT_TYPE, sQuery, CRecordset::readOnly)) { ... } The problem is that the statement that contains the call to the Open method sometimes takes about 2 minutes to execute (and sometimes works ok). Anyone have any idea of why this happens? And maybe an idea of how I can fix it (speed it up)?
-
Hi, I have an application in which I am loading data from a database (in this specific case a large database) into a grid in my GUI. So, I open the query into a recordset using the Open method as follows: sQuery.Format(_T("SELECT DISTINCT D.fieldA, DC.fieldB from TableDC DC, TableD D WHERE D.fieldA = DC.fieldA AND D.No = '3’ ORDER BY DC.fieldB")); if(!Open(AFX_DB_USE_DEFAULT_TYPE, sQuery, CRecordset::readOnly)) { ... } The problem is that the statement that contains the call to the Open method sometimes takes about 2 minutes to execute (and sometimes works ok). Anyone have any idea of why this happens? And maybe an idea of how I can fix it (speed it up)?
SWDevil wrote:
The problem is that the statement that contains the call to the Open method sometimes takes about 2 minutes to execute (and sometimes works ok). Anyone have any idea of why this happens? And maybe an idea of how I can fix it (speed it up)?
This may due to your DataBase doing some pending work..or your request is not scheduled by the Database engine..as well as its a ORDER query so it takes time to fetch the fields and sorting as well. Knock out 't' from can't, You can if you think you can :cool:
-
SWDevil wrote:
The problem is that the statement that contains the call to the Open method sometimes takes about 2 minutes to execute (and sometimes works ok). Anyone have any idea of why this happens? And maybe an idea of how I can fix it (speed it up)?
This may due to your DataBase doing some pending work..or your request is not scheduled by the Database engine..as well as its a ORDER query so it takes time to fetch the fields and sorting as well. Knock out 't' from can't, You can if you think you can :cool:
A_LaxmanThis may due to your DataBase doing some pending work..or your request is not scheduled by the Database engine..
can I somehow check if this happens and if it does, can I fix it?
A_Laxmanas well as its a ORDER query so it takes time to fetch the fields and sorting as well.
but this same query sometimes executes very quickly...