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

SqlCommand.ExecuteReader duration less than SQL Profiler batch duration

How a call to SqlCommand.ExecuteReader take less time to complete than the SQL batch itself as seen in SQL Profiler? I have the following simple code running in a console app which calls SqlCommand.ExecuteReader, which I time using a Stopwatch…
2
votes
2 answers

Only get single value from list executereader

I am trying to read values form my database. But why am I getting only values with no column name? this is my controller. that returns the values in JSON SqlCommand cmd = con.CreateCommand(); cmd.CommandText = "SELECT…
EagleFox
  • 1,367
  • 10
  • 34
  • 58
2
votes
2 answers

ExecuteReader CommandText property has not been properly initialized

First of all sorry if some of the code isn't right. I'm still new to using sql on vb.net I have the following code: Imports MySql.Data.MySqlClient Imports System.Data.SqlClient Public Class Form1 Private Sub btnLoad_Click(ByVal sender As…
ECATech
  • 23
  • 1
  • 2
  • 6
1
vote
3 answers

Why is ExecuteReader only giving me 1 row of data back?

I have this code and its only returning the first string [0] and errors on the rest of them saying the index is out of the array which means only 1 row is getting pulled BUT I DON'T KNOW WHY!!! MySqlConnection connection = new…
Devin Prejean
  • 105
  • 1
  • 2
  • 16
1
vote
2 answers

unexpected error when trying to execute stored procedure

I get the following exception when i try to execute specific stored procedure : Input string was in incorrect format my .cs : sQuery.Append("EXECUTE procedure get_department(" + dep_code + "," + emp_code + "," + batch_code + ")"); return…
Anyname Donotcare
  • 11,113
  • 66
  • 219
  • 392
1
vote
1 answer

Long-time SqlCommand.ExecuteReader() stored procedure execution when sys.dm_exec_procedure_stats.max_elapsed_time is short

I have an application that calls an Azure SQL stored procedure "report.GetReportCell". To call this procedure my app uses SqlCommand.ExecuteReader() method. Sometimes calls are too slow. In Dependency telemetry I see a lot of records with: my proc…
1
vote
1 answer

How to populate arraylist with SQL query?

I am developing a VB.NET ASPX file. This report is currently working but now I want to add a parameter which should be an array list displaying all records from below SQL query: " select distinct instrument_name AS instrument_name from FRUD.tblXref…
salvationishere
  • 3,461
  • 29
  • 104
  • 143
1
vote
1 answer

ExecuteReaderAsync() returns some rows at first but empty seconds later

What I'm trying to do is to call a stored proc using ado.net and get its result. I have tried to execute the stored proc in ssms and its working fine. But when I tried to run it through the code, the result is empty, so I tried to debug and here is…
sicKo
  • 1,241
  • 1
  • 12
  • 35
1
vote
1 answer

Need an example on how to use the ExecuteReader with a ParamArray

Can somebody please provide an example of how to use the ExecuteReader calling a stored procedure with a parameter array?
Ahd
  • 271
  • 2
  • 3
  • 7
1
vote
2 answers

Npgsql.PostgresException error on ExecuteReader when attempting to query PostgreSQL database in C# Winform

I'm trying to get a list of strings from a database query and put those in a ComboBox. The code that I'm attempting to do that with starts with the following on my from in a DataGridVew Cell Click event: // Bind combobox to dgv and than add list of…
marky
  • 4,878
  • 17
  • 59
  • 103
1
vote
1 answer

ExecuteReader requires an open and available Connection - current state is closed

all. I have been struggling with this issue since it raised its head late last night. Not sure WHY it is happening, but it is. What used to work with just ONE Artistcon.open() Now requires me to have it at every new "ExecuteReader". Below is a…
CodingEE
  • 129
  • 2
  • 14
1
vote
1 answer

SqlCommand.ExecuteReaderAsync stops firing InfoMessage event after first SELECT statement in a stored procedure

I have to use stored procedures for accessing data and also consume messages (like PRINT 'hello') sent from the DB engine. When I a use InfoMessage event of SQL connection and fill the data into DataTable, everything works perfect. However, when I…
Tom
  • 21
  • 1
  • 6
1
vote
2 answers

Fastest way to execute a SQL command from C#

I'm struggling with a SQL Server database where I want to keep references to which I add prices from several suppliers. I'm reading from a .xlsx file reference and price and storing the prices in a SQL Server database. I have to check if the ref…
Piotr Grociak
  • 93
  • 2
  • 8
1
vote
1 answer

not getting stored procedure output variable through ExecuteReader

here my code- using (SqlDataReader sqlDataReader = ExecuteReader(CommandType.StoredProcedure, StoredProcedures.AuthenticateUser, sqlParameter)) { isAuthenticated = Convert.ToBoolean(sqlParameter[2].Value); if…
ppp
  • 303
  • 2
  • 9
  • 22
1
vote
1 answer

Slow SafeDataReader loop

I have a vb.net/SQL Server client app in which I need to add a left join to an existing query. This same code in the data layer is used by asp.net to retrieve the data for the web version of the app. The next two code blocks show the entire original…
MBailey
  • 11
  • 1
1
2
3
8 9