Question : Disconnected Recordset Problem

I'm having a problem with a function I wrote.  Basically what it needs to do is run a select statement on one mysql database, if it returns empty, run the same select statement on a different mysql database.  The function then returns the recordset. The recordcount of the recordset is always -1.   If I take out     oDB.disconnect()   &  del oDB, it works.  Do I have to close the connection and delete the db object?  
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
def getRecordSet(conStr, sql, sysInfo):
    localDb = ""
    oDB = clsAdo()
    
    if (conStr.find("config") <> -1):
        localDb = sysInfo.configDbLocal
    elif (conStr.find("spd") <> -1):
        localDb = sysInfo.spdDbLocal
    
    if (localDb <> ""):
        if ( oDB.connect(localDb) == False ):
            displayErrorMsg("getRecordSet", "smt_utility.py", "Could not connect to the Database.", 1)
 
 
        oRS = oDB.getResultSet(sql)[0]
 
 
        if (oRS.EOF):
            oDB.Disconnect()
            if ( oDB.Connect(conStr) == False ):
                displayErrorMsg("getRecordSet", "smt_utility.py", "Could not connect to the Database.", 1)
 
    
            oRS = oDB.getResultSet(sql)[0]
 
            
    else:
        if ( oDB.connect(conStr) == False ):
            displayErrorMsg("getRecordSet", "smt_utility.py", "Could not connect to the Database.", 1)
 
  
    oRS = oDB.getResultSet( sql )
    
    oDB.disconnect()        
    del oDB
    return oRS
Open in New Window Select All

Answer : Disconnected Recordset Problem

I figured this out.
Random Solutions  
 
programming4us programming4us