I need help troubleshooting a reporting code in VB6, using oracle database.
earlier the code was running just fine, but recently its been giving the Runtime error 3669. I searched the net for this error and have found out that its because of timeout. In the Administrative tools -> ODBC, i have disabled the "enable query timeout" check but it still doesnt work. The query is being called through the OpemRecordset function.
Code:
    Set rstTemp = conPubs.OpenRecordset(SqlString1, dbOpenDynamic)
This is the SqlString1 that is being run here:
Code:
SqlString1 = "SELECT TO_CHAR(VIEW_DC_WT_SNAPSHOT_02.TIMESTAMP,'MM/DD/YY HH24:MI'), max(VIEW_DC_WT_SNAPSHOT_02.VALUE1), max(VIEW_DC_WT_SNAPSHOT_02.sname1), max(VIEW_DC_WT_SNAPSHOT_02.VALUE2), max(VIEW_DC_WT_SNAPSHOT_02.sname2), max(VIEW_DC_WT_SNAPSHOT_02.VALUE3), max(VIEW_DC_WT_SNAPSHOT_02.sname3), max(VIEW_DC_WT_SNAPSHOT_02.VALUE4), max(VIEW_DC_WT_SNAPSHOT_02.sname4), max(VIEW_DC_WT_SNAPSHOT_02.VALUE5), max(VIEW_DC_WT_SNAPSHOT_02.sname5), max(VIEW_DC_WT_SNAPSHOT_02.VALUE6), max(VIEW_DC_WT_SNAPSHOT_02.sname6), max(VIEW_DC_WT_SNAPSHOT_02.VALUE7), max(VIEW_DC_WT_SNAPSHOT_02.sname7), max(VIEW_DC_WT_SNAPSHOT_02.VALUE8), max(VIEW_DC_WT_SNAPSHOT_02.sname8), max(VIEW_DC_WT_SNAPSHOT_02.VALUE9), max(VIEW_DC_WT_SNAPSHOT_02.sname9), max(VIEW_DC_WT_SNAPSHOT_02.VALUE10), max(VIEW_DC_WT_SNAPSHOT_02.sname10), max(VIEW_DC_WT_SNAPSHOT_02.VALUE11), max(VIEW_DC_WT_SNAPSHOT_02.sname11), max(VIEW_DC_WT_SNAPSHOT_02.VALUE12), max(VIEW_DC_WT_SNAPSHOT_02.sname12)"
        
        SqlStringTmp = ", max(VIEW_DC_WT_SNAPSHOT_02.VALUE13), max(VIEW_DC_WT_SNAPSHOT_02.sname13), max(VIEW_DC_WT_SNAPSHOT_02.VALUE14), max(VIEW_DC_WT_SNAPSHOT_02.sname14), max(VIEW_DC_WT_SNAPSHOT_02.VALUE15), max(VIEW_DC_WT_SNAPSHOT_02.sname15), max(VIEW_DC_WT_SNAPSHOT_02.VALUE16), max(VIEW_DC_WT_SNAPSHOT_02.sname16) From VIEW_DC_WT_SNAPSHOT_02 where VIEW_DC_WT_SNAPSHOT_02.ID =" & KRSNWT.WELL_TEST_ID & " group by VIEW_DC_WT_SNAPSHOT_02.timestamp,VIEW_DC_WT_SNAPSHOT_02.id"
        
        SqlString1 = SqlString1 & SqlStringTmp
Running this query directly in the database, i get the result in around 3.5 minutes. so probably this is a problem of timeout. But how do i get around it? this code is not using the QueryDef method. it is using Recordset.

Quering the database with
Code:
Select count(*) from view_dc_wt_snapshot_02
gives the result 1067478. and this query took arnd 6 minutes to give the result.

So my two questions are: How to bypass the timeout? and How can i improve my query to make it go faster? P.S. this isnt my coding, i am here to troubleshoot this

How can this be improved?

Thanks