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
0
votes
1 answer

Generic mapping with Automapper to SQLite returns empty list

I'd like to create a generic data provider function which returns IEnumerable from the SQLite data read. Created the AutoMapper init: cfg.CreateMap() Then called the CompileMappings() and in the command itself the reader…
Paxsentry
  • 193
  • 2
  • 14
0
votes
1 answer

IDataReader to execute stored procedures

I am using IDataReader to get the data from db using stored procedure. ie something like this using (IDataReader Reader = SqlHelper.ExecuteReader(ConnectionString, "StoredProc1", sqlParam)) { while (Reader.Read()) { } } In that case…
Mahesh KP
  • 6,248
  • 13
  • 50
  • 71
0
votes
1 answer

dynamic create object from interface and set value

purpose: dynamic create object from interface and set values from IDataReader for now , i can dynamic create object type/instance from interface ,but when i set value from IDataReader , there is an error : "specified cast is not valid" i googled…
goldii
  • 242
  • 2
  • 18
0
votes
1 answer

Is property HasRows available for iDataReader?

I ask the above question because I am seeing something property HasRows in the QuickWatch window.. I am modifying someone else's code, and need to follow the patterns established. I have to query a SQL Server table to retrieve a row from a…
BarnumBailey
  • 391
  • 1
  • 4
  • 13
0
votes
0 answers

IDBCommand.ExecuteReader() not picking up SQL Server trace flags

I am running a long query, and using trace flag 2312 in SQL Server. I've noted that when using this trace flag my query returns all results at once, after roughly 20 minutes. when not using this trace flag my query returns rows continuously,…
Steven Hsu
  • 183
  • 1
  • 3
  • 15
0
votes
0 answers

Automapper custom mapping with IDataReader

I'm trying to map a DataTable to a DtoObject with AutoMapper. This works perfect only when I'm trying to add some custom mapping for a specific field it is not being mapped. using nuget packages: AutoMapper AutoMapper.Data Setup (using…
Rik
  • 513
  • 2
  • 9
0
votes
1 answer

Execution Timeout Expired when closing IDataReader

I'm retrieving huge amount of data from SQL Server. Everything works fine but when I try to close IDataReader inside using statement try { using (SqlConnection con = new SqlConnection(connString)) { con.Open(); …
mateskabe
  • 289
  • 2
  • 13
0
votes
1 answer

Index value issue in IDataReader implementation

I have implemented a class using IDataReader as part of a project which uses SqlBulkCopy. I have posted some of the relevant code here public bool Read() { var result = !fileStream.EndOfStream; if (result) { delimRow =…
0
votes
1 answer

Unable to cast object of type 'System.Data.SqlClient.SqlDataReader' to type 'System.Collections.Generic.IEnumerable'

I've been trying to understand why it's giving me this error because I'm not using SqlDataReader, I get that I'm using SQL Server and the Interface is returning the specific type but still I'm telling .NET to use IDataReader instead. Here's the…
Victor Alejandria
  • 120
  • 1
  • 3
  • 10
0
votes
1 answer

How to retrieve value from IDataReader that have multiple tables

I've been trying to get values from IDataReader recently an have been unable to get data from the second table I queried. Can someone please help me find a way to get them. Here is what i have so far: using (SqlCommand command = new…
MVCNoob
  • 76
  • 7
0
votes
0 answers

How to Mock ExecuteReader method?

I'm new to moq and setting up mocks so i could do with a little help. How do I mock up an ExecuteReader() using Moq? Update I have below code for ExecuteReader private void ExecuteGainLossCommand(AccountsContext dbContext, string query,…
Ajinkya Kasar
  • 3
  • 1
  • 1
  • 3
0
votes
1 answer

Why can't DataTable.Load(IDataReader) load one row?

I am using DataTable.Load(IDataReader) to load data from db. When I load one record, DataTable.Rows.Count shows a count of 0, but when I load more than record DataTable.Rows.Count shows the right Count. Does this mean DataTable.Load Method takes…
Angwenyi
  • 319
  • 1
  • 4
  • 16
0
votes
1 answer

How to get data type of a column?

I use Northwind sample database and ODBC. For my C# application I want to get the data type of a column as Type object (not as String), because I want to use the Type for some reasons. Example (taken from Northwind) - Table OrderDetails contains…
MagB
  • 2,131
  • 5
  • 28
  • 54
0
votes
0 answers

While loop keeps returning duplicate information

I have a function that is meant to get values from a SQL database table (called ProductProfiles) and display them inside a .csv document that users can download and view. The results are based on a drop down list's selection (called…
Dejsa Cocan
  • 1,539
  • 3
  • 19
  • 56
0
votes
1 answer

How can I execute a multi Join SQL query in c#

Using IDataReader in c# to pull a list of host names from a database that correspond to a specific business unit, but can't figure out what is wrong. I am guessing that there are too many arguments in the SQL statement, or perhaps the ExecuteReader…