Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted
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.

Afraits

"The avalanche has started, it is too late for the pebbles to vote"

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...