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

How to map a DataReader to class properties and maintain performance?

Preamble: All data connection strings, connections, etc are created using DbProviderFactories. Code is mixed C# and VB.Net from mulitple libraries. I am mapping a DbDataReader to entities and have some benchmarks: [0] retrieved 159180 records in…
IAbstract
  • 19,551
  • 15
  • 98
  • 146
8
votes
3 answers

Performance issues to iterate results with C# SQLite DataReader and attached database

I am using System.Data.SQLite and SQLiteDataReader in my C# project. I am facing performance issues when getting the results of a query with attached databases. Here is an example of a query to search text into two databases : ATTACH "db2.db" as…
Morgan M.
  • 846
  • 2
  • 9
  • 27
8
votes
3 answers

SQL Server and SqlDataReader - Trillion Records - Memory

I've never tried this - so I don't know if I'd run into memory issues. But can a SqlDataReader read a trillion records? It's all streamed correct? I'm a little green to what the SQL/TDS protocol is doing under the covers. UPDATE Translate Trillion…
BuddyJoe
  • 69,735
  • 114
  • 291
  • 466
8
votes
6 answers

C# Object null check

I read my database using DataReader. and some row does not have fdate value. so when I Convert the null date to DateTime then Error occurs. How can I check the field empty or not? AdsCommand cmd = conn.CreateCommand(); cmd.CommandText = "select…
Expert wanna be
  • 10,218
  • 26
  • 105
  • 158
7
votes
7 answers

What is the best way to load huge result set in memory?

I am trying to load 2 huge resultsets(source and target) coming from different RDBMS but the problem with which i am struggling is getting those 2 huge result set in memory. Considering below are the queries to pull data from source and target: Sql…
I Love Stackoverflow
  • 6,738
  • 20
  • 97
  • 216
7
votes
2 answers

Entity Framework,There is already an open DataReader associated with this Connection which must be closed first

In the "each", when run the "FirstOrDefault" will error "There is already an open DataReader associated with this Connection which must be closed first.". How to do ? public int SetUser(string[] dIds, string pId) { using (var scope =…
clark wu
  • 406
  • 1
  • 5
  • 9
7
votes
5 answers

How to add columns to DataReader

My goal is to retrieve data from a data source, add some metadata to it and insert it to another target. The target has schema with four more columns then the source (calculated columns). I am using SqlBulkCopy, which requires a reader with all…
Yosi Dahari
  • 6,794
  • 5
  • 24
  • 44
7
votes
4 answers

Access a specific row in DataReader

I have a datareader to display a list of gameweeks in a js carousel. I need to be able to add an if statement to change the div class of the current gameweek. This is my current code: if (dReader.HasRows) { while (dReader.Read()) { …
JackofAll
  • 517
  • 4
  • 13
  • 23
7
votes
7 answers

How to use datareader with null values

Say I have this class: class myclass { public int Field1{ get; set; } public int? Field2 { get; set; } //Note Field2 is nullable } I'm trying to populate a generic list with data coming from a database. As GetSqlInt32 implements INullable…
Anthony
  • 7,210
  • 13
  • 60
  • 70
6
votes
6 answers

MySqlDataReader: DataTable.Fill(reader) throws ConstraintException

I have two tables orders and orderdetails table orders (PK = id, UNIQUE index on orderno) |id|orderno| | 1|1000 | | 2|1001 | table orderdetails (PK = id) |id|orderid|item|qty| | 1| 1|ABC | 3| | 2| 1|XYZ | 4| Now I want to query the…
Jürgen Steinblock
  • 30,746
  • 24
  • 119
  • 189
6
votes
1 answer

typeerror: string indices must be integer pandas datareader

I want to print out SPY's stock data however it keeps shows typeerror: string indices must be integer import pandas_datareader.data as web spy = web.get_data_yahoo('SPY',start='2022-12-23',end='2022-10-24') print(spy)
umklapper
  • 105
  • 1
  • 1
  • 5
6
votes
6 answers

How to fix new unable to read URL error in python for yahoo finance

I have been using this code to extract (scrape) stock prices from Yahoo Finance for the last year, but now it produces an error. Does anyone know why this is happening and how to fix it? # Importing necessary packages from pandas_datareader import…
iceAtNight7
  • 194
  • 1
  • 2
  • 10
6
votes
5 answers

Extract from DataRow or DataReader with one function

I'm looking for a solution for how to be able to extract data from a database when using either a DataRow and a DataReader with only one function (or one base function). My problem stems from the fact that sometimes I need a DataReader and sometimes…
Nate32
  • 251
  • 2
  • 5
  • 12
6
votes
4 answers

Object of type 'System.Int16' cannot be converted to type 'System.Nullable`1[System.Int32]

I've a method that generates list of class type from data of data reader. if (datareader != null && datareader .HasRows) { Dictionary pDict= GetPropertyDictionary(); var fields = GetFieldNames(datareader ); while…
Priya
  • 1,375
  • 8
  • 21
  • 45
6
votes
2 answers

Pulling stock information using pandas datareader

I am using pandas datareader to pull stock information for a given range of dates. For example: import pandas_datareader.data as web import datetime as dt start = dt.datetime(2018,3,26) end = dt.datetime(2018,3,29) web.DataReader('IBM','yahoo',…
Brian
  • 2,163
  • 1
  • 14
  • 26
1 2
3
52 53