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
0
votes
2 answers

c# SqlDataReader throwing syntax error, but the command runs fine in SQL Server?

I'm getting a syntax error from my SQL command shown in the code below. The error is happening on the ExecuteReader line, saying Incorrect syntax near the keyword 'JOIN'.' I have no idea why it's throwing a syntax error, the command works…
0
votes
1 answer

ExecuteReader Timing Out

I'm trying to create a login page. I get the users ID and password as parameters, and I want to access my database and compare them, but when I execute the query using ExecuteReader, the query always times out. The database itself is very very…
user74671
  • 21
  • 4
0
votes
2 answers

SqlDataReader.ExecuteReader(); returning null object even if all parameters are provided

SqlConnection connection = Connect(); SqlCommand command = new SqlCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = sprocName; command.Connection = connection; //loop through the dictionary foreach (string key in…
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
4 answers

ExecuteReader requires open Connection. Current state: Broken

I'm using StructureMap to inject a LINQ data context (DB class) into my repositories for read queries on a HTTP-context basis, which are queried via a service layer. Everything works fine for a few hours until I get a "Broken" Connection…
Petrus Theron
  • 27,855
  • 36
  • 153
  • 287
0
votes
1 answer

Using ExecuteScalar() results in a call to ExecuteReader() with a "default" CommandBehaviour?

Stack trace shows that ExecuteReader is the underlying method for ExecuteScalar.While digging for associated commandbehaviour, i found the post below - stating that the commandbehaviour.default is used by the reader. Does ExecuteScalar() have any…
MZZ
  • 3
  • 1
0
votes
0 answers

SQL Server performance for high concurrent access

One win service developed by C# and based on SQL Server. I created a SqlConnection and then do ExecuteReader, but I face a problem when there is a high concurrent access. On my local machine, code as below, average is 1.2s for one execution.…
Raymond He
  • 127
  • 5
0
votes
1 answer

How to convert petapocohelper executereader to List [C#]

I'm developing .cs code to get data from a Stored Procedure and store it to a List but i'm having trouble getting all datasets to the List. The SP: ALTER PROCEDURE [_testSchm].[_test_sp] @paramINint int, @paramINnvarchar nvarchar(max), …
0
votes
2 answers

ExecuteReader for executing Insert/Update query

Ok so I was just given this old vb.net(2008) program to make some changes to and I found something weird. The Insert/Update queries are being executed with ExecuteReader, it goes something like this Dim sqlcommand as new SqlCommand("Insert query",…
crimson589
  • 1,238
  • 1
  • 20
  • 36
0
votes
0 answers

ExecuteReader requires an open and available Connection

I just started a new job and I'm dealing with a lot of code for websites that I did not write. This error keeps happening in one of the websites but not all the time, sometimes the website works just fine and goes down for a few minutes or sometimes…
0
votes
2 answers

Fill datagridview with SQL Server table data

I'm trying to fill a datagridview with SQL Server table data and I get an error: ExecuteReader: Connection property has not been initialized. How do I fix this ? private void BlackListLoad() { DataTable dt = new DataTable(); …
Luka
  • 15
  • 1
  • 5
0
votes
1 answer

ADO.Net - Performance difference between Execute Reader and Execute Scalar

I know the purpose of Execute Reader and Execute Scalar. But Execute Reader can serve the purpose of Execute Scalar. So why to use Execute Scalar? Is there any performance difference between them? Which is faster? Thanks.
0
votes
1 answer

How to capture duplicate values and show message box while reading from database?

I've a DataGrid which uses a list object. I would like to prevent users from entering duplicate values into database. My stored procedure already prevents duplicate data from entering into database but I would like to show a more descriptive…
Mihika
  • 1
  • 3
0
votes
2 answers

ExecuteReader: Connection property has not been initialized. in vb.net 2010

I have an error about "invalidoperationexception was unhandled" My Code Is Like This : Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click sql = "select * from tb_user where user_name='" +…
0
votes
1 answer

Change column value using condition after gridview databind

I am displaying data in Gridview from three tables using join. But I want to change a field using condition. I kept my "status" as "1" and "0". For "1" I want to display "Selected" and for "0" I want to display "Rejected". Below is my code: void…
Pranjal
  • 3
  • 2
1 2 3
8 9