LeifW Posted August 2, 2005 Posted August 2, 2005 Hi, I have a problem which I hope is easy. I have a program written in C#. I'm using a DataReader to retrive 4 rows of data from a Sybase database. Everything seems to work fine except when I call the DataReader.Close() method. The system just hangs. I'm using the OleDbDataReader. When I trace through the code using the debugger, I see that correct data is being returned in a timely manner. Also if I use Odbc objects (OdbcConnection, OdbcDataReader, OdbcCommand) with the appropriate connect string, everything works fine. Any help or guidance would be appreciated. Thanks. Here's the code. OleDbConnection myConn = new OleDbConnection(Session["ConnectionString"].ToString()); string mySelectQuery = "select id from Cashflow where number = 464000"; OleDbCommand myCommand = new OleDbCommand(mySelectQuery,myConn); OleDbDataReader dr; myConn.Open(); dr = myCommand.ExecuteReader(); while (dr.Read()) { ListBox2.Items.Add(dr[0].ToString()); } dr.Close(); // <---- System hangs here! myConn.Close(); Thanks, LeifW Quote
Afraits Posted August 2, 2005 Posted August 2, 2005 Try calling cancel on the underlying command object within the reader - can't remember the syntax offhand but the underlying command object has work to do once the reader is finished - if you call the command object's cancel method before closing the reader it may help. Quote Afraits "The avalanche has started, it is too late for the pebbles to vote"
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.