datareader

Invalid attempt to call FieldCount when reader is closed

Hello guys/girls The error above occurs when I try to do a dataReader.Read on the data recieved from the database. I know there are two rows in there so it isnt because no data actually exists. Could it be the CommandBehavior.CloseConnection, causing the problem? I was told you had to do this right after a ExecuteReader? Is this correc...

How to convert DataSet Value to DataReader?

How to convert DataSet Value to DataReader? ...

Fill DataTable from DataReader row by row

Hello, i want to fill a Datatable with a Datareader row by row but get an exception because the reader's columns have a different order than the Datatable's columns. Why and how does a Datatable loads itself with a Datareader correctly, even so it has a column collection with different order? I need to calculate values for every row s...

Pipe SQL to a file

Any idea how to pipe the results of ... DECLARE @session_name VARCHAR(200) = 'test_trace' SELECT pivoted_data.* FROM ( SELECT MIN(event_name) AS event_name, MIN(event_timestamp) AS event_timestamp, unique_event_id, CONVERT ( BIGINT, MIN ( CASE ...

how to use the datareader across multiple functions in a single .net web page.

Is it better to declare the datareader as public or declare as local to each and every function in which we use the datareader in a .net page? ...

Measure stored procedure duration

Hi, In my application I want to know the execution time for a stored procedure. My pattern is to execute reader and get the data reader and read the results. The reader return immediately and I don’t know the stored procedure execution time. I cannot put the timers after the reader because I want to have an extension method to encapsu...

Error in DataReader is not closed

Can anyone help me on how this error came up There is already an open DataReader associated with this Connection which must be closed first. the error fails when it trying to read this code. transConn = mySqlConn.BeginTransaction(IsolationLevel.ReadCommitted) Is there is a connection between the Datareader and in initializing the tr...

How to handle multiple ResultSets, each with multiple Rows? IDataReader.NextResult() ending Read()

How to handle multiple ResultSets, each with multiple Rows? The call to NextResult() breaks the while loop. Some of my SPs return multiple ResultSets. I'm handling these with NextResult() but when I do and my SP only has a single ResultSet, I see the while loop with Read() finishes leaving me with only the first Row. Without the call t...

DataAdapter returns a empty rowset, but DataReader returns data.

Hi, I execute a query that calls a SP, that SP returns data... but when I call it with a DataAdapter I get no result data, if use a DataReader instead... then I get data. The database is SQL Server and the code is using OleDb for reasons I cannot change. These two calls returns diferent things: String commandText = "Declare @retur...

ADO.NET Performance : Which Approach will faster and resonable?

Hi all, I want to select certain amount of data from one table. Based on those data, I want to check another two tables and insert into 2 tables. So I want to iterate the resulted data. Which way is better(faster) and reasonable using DataReader or DataTable? Thanks in advance RedsDevils ...

What to use for a datagrid with a lot of data?

Hi, Found this interesting interview question: You need to display the sales data for your division for the past 5 years in a DataGrid on a Web Form. Performance is very important. What would be the best strategy to use in retrieving the data? a)Use a DataReader object to retrieve the data for the DataGrid. b)Use a DataSet object to ...

How to 'select' the current identity value for a table?

dbcc checkident (MyTable, NORESEED) Will show the identity value in a message. I can't see the message as I need to select the identity value through a DataReader. Anyone any ideas? Thanks folks ...