Questions tagged [executereader]

A Microsoft .NET method that sends the `CommandText` to the `Connection` and builds a `SqlDataReader`.

Namespace: System.Data.SqlClient
Assembly: System.Data (in System.Data.dll)

public SqlDataReader ExecuteReader()

Return Value

  • Type: System.Data.SqlClient.SqlDataReader
  • A SqlDataReader object.

http://msdn.microsoft.com/en-us/library/9kcbe65k(v=vs.110).aspx

128 questions
23
votes
2 answers

C# Invalid attempt to call Read when reader is closed

I am having Invalid attempt to call Read when reader is closed error when I am doing 3 tier project in C# language. What I am trying to do is retrieve address data column by joining two tables together and display in a drop down list. Here is my…
user2531590
12
votes
4 answers

ExecuteReader() in Powershell script

I'm trying to read data from a SQL table in a powershell script. I can see the data in reader object, but when reading it using While (readerobject.read()){}, it's not going inside the loop. Powershell: $cmd = $sqlConn.CreateCommand() …
Geeth
  • 5,282
  • 21
  • 82
  • 133
6
votes
5 answers

Invalid attempt to call FieldCount when reader is closed

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…
ClareBear
  • 1,493
  • 6
  • 25
  • 47
5
votes
0 answers

ExecuteReader Much Slower Than SSMS

My issue started with Entity Framework query executing very slowly (~2 minutes). So I started investigating Meanwhile it seems the issue is also in standard SqlConnection I have a pretty simple query SELECT 1 AS [C1], [Extent1].[OldReleaseID] AS…
Yisroel M. Olewski
  • 1,560
  • 3
  • 25
  • 41
5
votes
2 answers

An OLE DB Provider was not specified in the ConnectionString. 'Provider=SQLOLEDB;

i trying to run query using C#, i am getting the following problem An OLE DB Provider was not specified in the ConnectionString. An example would be, 'Provider=SQLOLEDB; my code string strConString =…
Noora
  • 319
  • 3
  • 10
  • 26
4
votes
2 answers

Execute Reader wait operation time out error

stuck on this since few days please help. I have tried a lot of solutions like increase connection timeout in web config: below is my error code. Server Error in '/' Application. The wait operation timed out Description: An unhandled exception…
Jayesh Patel
  • 53
  • 1
  • 1
  • 6
3
votes
1 answer

Combining SQL `raiserror` with `select` in C#

I want to know if there is a way of using both SQL raiserror and retrieving the selected result in C#. ExecuteReader() in C# will throw an exception when raiserror occurs, but I still want to use the reader to capture any data returned. Below is a…
Peet Brits
  • 2,911
  • 1
  • 31
  • 47
3
votes
0 answers

SqlDataReader hangs on GetValue() method and SNIReadSyncOverAsync

We have an extremely weird problem at hand. The .Net SqlDataReader object gets stuck while reading a value on GetValue() method. There are no exceptions and it does not timeout for at least more than 10 minutes which is really long time. After…
murtazat
  • 399
  • 3
  • 12
3
votes
2 answers

How to convert IDataReader into Stream in C#

In my WCF service, I am retrieving data from SQL server using Command.ExecuteReader() method. The data size is very large (around 1+ GB) and transferring this data to client over netTcp binding. I am planning to implement stream mode instead of…
Abhash786
  • 881
  • 2
  • 24
  • 53
3
votes
2 answers

ExecuteReader with Oracle array binding

I'm trying to improve performance of my Oracle SQL queries by using array binding to an OracleParameter. This is basically what I'm trying to do: List IDValList = new List(); IDValList.Add( "IDOne"…
MonkeyWrench
  • 1,809
  • 2
  • 24
  • 48
2
votes
3 answers

ExecuteReader is returning only 1 value

I am using an ExecuteReader to return the values of QuestionText when QuestionnaireID matches my query. (See Database Design) However my problem is that when I run the project my ExecuteReader only returns the last value that was input. For example,…
HGomez
  • 1,494
  • 8
  • 32
  • 42
2
votes
2 answers

Is it possible to use ExecuteReader() twice?

I'm programming a database manager for a gameserver called OTServer, and I'm having problems using executereader() the second time. Here's code: private void button1_Click(object sender, EventArgs e) { Form1 f = new Form1(); …
Marcus
  • 441
  • 3
  • 15
  • 27
2
votes
2 answers

SQL Server Column to Combobox?

I have a table called Product. One of the columns of this table is called Naam. It's the name of the product. When you press on the button, all product names have to be added to the combobox. So if I have 2 products: Cola & Fanta. The program has to…
Cihan Kurt
  • 343
  • 1
  • 5
  • 21
2
votes
1 answer

Execute SQL Script with GO Batch Separators and Read Results

I have a SQL script with GO batch separators that I am trying to execute from C# code. When I use Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery, it works great. It blows up on…
Dan Forbes
  • 2,734
  • 3
  • 30
  • 60
2
votes
3 answers

how to use executereader to read one value

I want to read an int value from my table. but I faced with error this is my code. please help me to edit my code. sqlc = new SqlConnection(ConnectionString); SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.Text; …
user3051479
  • 45
  • 2
  • 6
1
2 3
8 9