Questions tagged [idatareader]

IDataReader is a Microsoft .NET interface which can be used to read data coming from a database. Use this tag for questions about using this interface.

Provides a means of reading one or more forward-only streams of result sets obtained by executing a command at a data source, and is implemented by .NET Framework data providers that access relational databases.

References:

Related questions/examples:

Also see .

120 questions
2
votes
5 answers

C# Reader Disposal Review

I am using the Enteprise Library to query my database. When I run a query, I am relying on stored procedures. Currently, I am using code that looks like the following: Database database = DatabaseFactory.CreateDatabase(); DbCommand command =…
Villager
  • 6,569
  • 22
  • 65
  • 87
2
votes
2 answers

Most efficient way to map IDataReader to a C# object, also catering for deep-copy?

we have a scenario where we use Enterprise Library Data package for the purposes of our data access needs. We have implemented a Generic Data Reader to hydrate our data into business objects. However we are looking for a more efficient way to do…
2
votes
1 answer

Best way to read IDataReader for WebApi

I have a WebApi action that returns dynamic result based on Sql query. Currently using the following function to convert IDataReader which works fine, but it creates a Dictionary object for each row. I was wondering if there is a better way to do…
2
votes
2 answers

IDataReader vs DataTable; pros and cons

I am working on doing a large scale insert/update operation. So I am using SqlBulkCopy. SqlConnection myConnection = new SqlConnection(myConnectionString); try { myConnection.Open(); SqlBulkCopy myCommand = new SqlBulkCopy(myConnection); …
Devraj Gadhavi
  • 3,541
  • 3
  • 38
  • 67
2
votes
1 answer

AutoMapper TypeConverter not getting called when mapping IDataReader

I have a few models that I would like to map using AutoMapper. Automapper is set to map from an IDataReader to the model class. The issue is that I need to have a ITypeConverter set on my mapper so that I can enumerate a limited amount of times for…
RobbieK
  • 115
  • 7
2
votes
1 answer

How to create custom class w/ IDataReader from LumenWorks (Fast CSV Reader) to use SqlBulkCopy while having several different file versions?

I have decided to replace/convert DataTable to IDataReader due to memory issues. After quite a while of Google & MSDN searches, I came across this at…
fletchsod
  • 3,560
  • 7
  • 39
  • 65
2
votes
2 answers

IDataReader serialization error

I have an ASP.NET page which houses a Gridview. I am trying to bind an IDataReader object to the grid. This IDataReader object is assigned by calling a few more layers of code(actually other .ent project dlls that form the Controller layer and the…
SARAVAN
  • 14,571
  • 16
  • 49
  • 70
2
votes
1 answer

Disposing SqlConnection from a base DAL class when calling ExecuteReader

I've been assigned on a project where the DAL consists of a base class with functions to return IDataReader, an Object (int, string and the like), or a DataSet. An ExecuteNonQuery function also exists. This DAL only accesses USPs (SQL Server), and…
synhershko
  • 4,472
  • 1
  • 30
  • 37
2
votes
2 answers

Best practices for getting around DB differences with an IDataReader

I have a simple value object which I populate with data from an IDataReader (could be the result of a query to either an Oracle or MS SQL database). The factory method for this object looks something like the following: internal static SomeClass…
jpoh
  • 4,536
  • 4
  • 35
  • 60
1
vote
1 answer

Object reference not set to an instance of an object. with IDataReader

I have some code that is supposed to connect with a database and populate some fields with existing information that is on the table. I have run into the Object refrence not set to an instance of an object on the line with my IDataReader IDataReader…
Joe W
  • 1,567
  • 6
  • 23
  • 36
1
vote
2 answers

Could not read values using IDataReader

I want to read data to a list from database. I tried the following code public List StoredProcedureForIList(string spName, params IDataParameter[] commandParameters) { List list = new List(); T item; Type listItemType =…
Shibin V.M
  • 411
  • 4
  • 9
  • 17
1
vote
1 answer

Adding a secondary data source to an ASP.NET data repeater

I have an ASP.NET data repeater. This is currently set to a data source obtained from an SQL query, as follows: IDataReader dr = GetData(sql); myRepeater.DataSource = dr; myRepeater.DataBind(); This works fine, but what I want to do now is to call…
Paul Michaels
  • 16,185
  • 43
  • 146
  • 269
1
vote
3 answers

Does a IDataReader get automatically get closed when set as a datasource?

When you assign an active IDataReader object to either a Repeater, GridView, etc., does it automatically get closed upon completion of the DataBind method call or do we still need to explicitly close it ourselves? this.sampleRepeater.DataSource =…
Dan Appleyard
  • 7,405
  • 14
  • 49
  • 80
1
vote
0 answers

Why csv file doesnt show special characters in C#?

I have this code used on my application to convert xls file to csv file. Excel.IExcelDataReader excelReader = Excel.ExcelReaderFactory.CreateBinaryReader(stream); DataSet result =…
1
vote
2 answers

IDataReader is closed when I try to return a tuple

I'm trying to return an HTTP Response that consists of an array of records I've selected from a database. But I'm having trouble mapping my IDataReader to an Enumerable. Here's the part of my code that's relevant: namespace Web.Api.Controllers { …
John
  • 32,403
  • 80
  • 251
  • 422