Provides a way of reading a forward-only stream of rows from a SQL Server database.

learn more… | top users | synonyms

76
votes
14answers
49k views

Check for column name in a SqlDataReader object

How do I check to see if a column exists in a SqlDataReader object? In my data access layer, I have create a method that builds the same object for multiple stored procedures calls. One of the ...
48
votes
14answers
46k views

SQL Data Reader - handling Null column values

I'm using a SQLdatareader to build POCOs from a database. The code works except when it encounters a null value in the database. For example, if the FirstName column in the database contains a null ...
32
votes
5answers
17k views

Can you get the column names from a sqldatareader?

After connecting to the database, can I get the name of the all the columns that where returned in my sqldatareader?
21
votes
12answers
8k views

Is there anything faster than SqlDataReader in .NET?

I need to load one column of strings from table on SqlServer into Array in memory using C#. Is there a faster way than open SqlDataReader and loop through it. Table is large and time is critical. ...
20
votes
5answers
51k views

how to get number of rows using SqlDataReader in C#

my question is about how to get number of rows using SqlDataReader in C#. I've seen some answers around the net about this but none were clearly defined except for one that states to do a while loop ...
15
votes
5answers
17k views

How to (efficiently) convert (cast?) a SqlDataReader field to its corresponding c# type?

First, let me explain the current situation: I'm reading records from a database and putting them in an object for later use; today a question about the database type to C# type conversion (casting?) ...
14
votes
9answers
48k views

how to check if a datareader is null or empty

I have a datareader that return a lsit of records from a sql server database. I have a field in the database called "Additional". This field is 50% of the time empty or null. I am trying to write ...
11
votes
10answers
11k views

DataReader or DataSet when pulling multiple recordsets in ASP.NET

I've got an ASP.NET page that has a bunch of controls that need to be populated (e.g. dropdown lists). I'd like to make a single trip to the db and bring back multiple recordsets instead of making a ...
11
votes
2answers
3k views

Multiples Table in DataReader

I normally used DataSet because It is very flexible. Recently I am assigned code optimization task , To reduce hits to the database I am changing two queries in one procedure. one Query returns the ...
10
votes
6answers
2k views

DataReader - hardcode ordinals?

When returning data from a DataReader I would typically use the ordinal reference on the DataReader to grab the relevant column: if (dr.HasRows) Console.WriteLine(dr[0].ToString()); (OR ...
10
votes
1answer
207 views

What does the buffered parameter do in Dapper dot net?

Dapper dot net has a buffer parameter (a bool), but as far as I can tell the only thing it does is cast the result to a list before returning it. As per the documentation: Dapper's default ...
10
votes
2answers
683 views

How To perform a SQL Query to DataTable Operation That Can Be Cancelled

I tried to make the title as specific as possible. Basically what I have running inside a backgroundworker thread now is some code that looks like: SqlConnection conn = new ...
7
votes
2answers
1k views

How to make streams from BLOBs available in plain old C# objects when using SqlDataReader?

This is the scenario: We store files, e.g. relatively large documents (10-300MB), in blobs in our MSSQL database. We have a very small domain model so we use the clean SqlDataReader approach for ...
7
votes
3answers
270 views

How to Change Column Name In DataReader In C#?

I have SqlDataReader that gets returned from a ExecuteDataReader statement. All I want is: change some column name in the data reader, just before binding to grid. Here's the situation: First I ...
6
votes
7answers
599 views

Should I implement IDisposable here?

My method which calls SQL Server returns a DataReader but because of what I need to do - which is return the DataReader to the calling method which resides in a page code-behind - I can't close the ...

1 2 3 4 5 29
15 30 50 per page