Questions tagged [datareader]

A DataReader reads a forward-only stream of rows from a data source.

A DataReader reads a forward-only stream of rows from a data source. This tag is for questions about creating or using a datareader in code.

782 questions
4
votes
2 answers

Using SqlTransaction with SqlDataReader

There are plenty of people talking about it online, but this just doesn't seem to work. This is the exception that I get: This SqlTransaction has completed; it is no longer usable. Here is the code using (SqlConnection locationConnection = new…
ReddShepherd
  • 467
  • 1
  • 11
  • 24
4
votes
2 answers

Using MySQL Data Reader

I'm not familiar with using Data Reader, i need help with the following code, i want to retrieve a single data from the database. MySqlDataAdapter data = new MySqlDataAdapter(cmd); conn.Open(); DataTable dt =…
Kevin Rodriguez
  • 181
  • 2
  • 3
  • 15
4
votes
1 answer

Lazy pub/sub in zeromq, only get last message

I'am trying to implement a lazy subscriber on zeromq from the example wuclient/wuserver. The client is way slower than the server, so it must get only the last sent message by the server. So far the only way i've found to do that, is by…
Mathieu Westphal
  • 2,544
  • 1
  • 19
  • 33
4
votes
1 answer

C# DataReader issue when used with .AsInputStream() converted stream

I need to do various reads on a stream for a decryption process. (for WinRT project) For one, I'd like to do a ReadByte() to get the first byte of the stream. There-after I'd like to read a few bytes into an array, and then read the rest of the…
4
votes
2 answers

DataReader - read data with unknown length

I have established a connection with a Tomcat java server. After sending login data, the server responds. The length of the response is not known. So I'm trying to read byte after byte using DataReader.UnconsumedBufferLength DataReader din = new…
Alexander Ciesielski
  • 10,506
  • 5
  • 45
  • 66
4
votes
1 answer

Processing excel files with data reader: ExecuteReader() buffers entire file

I'm running into a peculiar issue when trying to process large excel files (300mb+) using a data reader. The following code illustrates the way I open the excel file and iterate over the rows in sheet 'largesheet$': const string inputFilePath =…
chrisv
  • 563
  • 1
  • 6
  • 10
4
votes
3 answers

While and IF in data reader

How I will combine the while and if in data reader? I tried this but in while DR1.Read it does not gives me all the result if(DR1.Read()) { while(DR1.Read()) { flowLayoutPanel1.Controls.Add(label); } } else MessageBox.Show("No results…
Karlx Swanovski
  • 2,869
  • 9
  • 34
  • 67
4
votes
3 answers

Java make a copy of a reader

I have a BufferedReader looping through a file. When I hit a specific case, I would like to continue looping using a different instance of the reader but starting at this point. Any ideas for a recommended solution? Create a separate reader, use…
tinkertime
  • 2,972
  • 4
  • 30
  • 45
4
votes
4 answers

How to count rows in MySqlDataReader?

I have successfully switched my project from odbc.datareader to mysql.datareader. The problem is that with the first one /odbc datareader), the AffectedRows property retrieves the number of rows correctly even when it was pure query. But it doesn…
Petr
  • 7,787
  • 14
  • 44
  • 53
4
votes
3 answers

How to retrieve all fields for a given record using OracleDataReader?

My question, which is similar to this one, is how can I use OracleDataReader to retrieve all the fields for a given record? Currently, I've been using this method, which returns only one column value at a time: public string Select_File(string…
user1985189
  • 669
  • 5
  • 16
  • 25
4
votes
2 answers

DataReader Behaviour With SQL Server Locking

We are having some issues with our data layer when large datasets are returned from a SQL server query via a DataReader. As we use the DataReader to populate business objects and serialize them back to the client, the fetch can take several minutes…
Graham
  • 305
  • 1
  • 5
  • 11
4
votes
2 answers

Can I avoid the open DataReader exception when using nested commands?

Can I avoid the open DataReader exception ("There is already an open DataReader associated with this Command which must be closed first.") when using constructs like this one? public void FirstMethod() { using (var command =…
Oliver Hanappi
  • 12,046
  • 7
  • 51
  • 68
4
votes
5 answers

Checking whether DataReader is empty

My code does not run when the DataReader is empty. Below is my code. My work is about Date Scheduling. And my problem is about a holiday constraint. When the user enters the dates (start date and end date), the program will check whether the entered…
Kevin James
  • 87
  • 3
  • 4
  • 10
4
votes
3 answers

Invalid attempt to Read when reader is closed

I have a common database class for my application and in that class i have a function public MySqlDataReader getRecord(string query) { MySqlDataReader reader; using (var connection = new…
GajendraSinghParihar
  • 9,051
  • 11
  • 36
  • 64
4
votes
3 answers

ASP.NET, Right way to use DataReader

I want to know right way to use DataReader. (C# and Advantage Database) Assuming that I have Order,Item and Customer tables in my database. and I need to read the data from each tables in a cs file. So I opened the database connection and read data…
Expert wanna be
  • 10,218
  • 26
  • 105
  • 158