If i have a function which would like to return a OleDbDataReader variable... is it possible??
I discover when my OleDbConnection is close thus the OleDbDataReader variable also contains nothing.
Attached is my function. Pls help to identify what i have did wrong....
Code:public static OleDbDataReader DB_Query(string sSQL) { DOMConfigurator.Configure(); OleDbConnection DBConn = null; OleDbCommand DBCmd = null; OleDbDataReader DBReader = null; using (DBConn = new OleDbConnection(DBCONNECTION)) { try { DBConn.Open(); DBCmd = new OleDbCommand(sSQL, DBConn); DBReader = DBCmd.ExecuteReader(); DBConn.Close(); } catch (Exception e) { log.Error(e.Message, e); } finally { DBConn.Close(); DBConn = null; DBCmd = null; } } return DBReader; }




Reply With Quote