|
-
March 24th, 2008, 08:00 AM
#1
Function return OleDbDataReader variable
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;
}
-
March 24th, 2008, 08:16 AM
#2
Re: Function return OleDbDataReader variable
have you tried loading a datatable with the reader. If there are no rows I would think your sql statement is messed up.
-
March 24th, 2008, 09:01 AM
#3
Re: Function return OleDbDataReader variable
 Originally Posted by zdavis
have you tried loading a datatable with the reader. If there are no rows I would think your sql statement is messed up.
when inside the function the OleDbDataReader is still holding data... but after connection is close... it become nothing inside... so when i return that is an error in the function which call it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|